summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/formfiller
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-07-22 15:14:14 -0700
committerTom Sepez <tsepez@chromium.org>2015-07-22 15:14:14 -0700
commit3c012fef2bb72c8ec1faa73e11ee35539b2559d6 (patch)
treeb88cb30a45a615b89cdb380f1f62d270ce540fb9 /fpdfsdk/src/formfiller
parent4eb4d7f6c707cc2c23c806aa540d055c8832b55d (diff)
downloadpdfium-3c012fef2bb72c8ec1faa73e11ee35539b2559d6.tar.xz
Re-land else-after-returns
Revert "Revert "Fix else-after-returns throughout pdfium."" This reverts commit 4eb4d7f6c707cc2c23c806aa540d055c8832b55d. Fix one naming conflict. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1243953004 .
Diffstat (limited to 'fpdfsdk/src/formfiller')
-rw-r--r--fpdfsdk/src/formfiller/FFL_ComboBox.cpp556
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp1347
-rw-r--r--fpdfsdk/src/formfiller/FFL_TextField.cpp531
3 files changed, 1198 insertions, 1236 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
index d3a494405f..841b45ecba 100644
--- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
+++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
@@ -14,7 +14,7 @@
/* ------------------------------- CFFL_ComboBox ------------------------------- */
CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) :
- CFFL_FormFiller(pApp, pAnnot), m_pFontMap( NULL )
+ CFFL_FormFiller(pApp, pAnnot), m_pFontMap( NULL )
{
m_State.nIndex = 0;
m_State.nStart = 0;
@@ -28,375 +28,363 @@ CFFL_ComboBox::~CFFL_ComboBox()
PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam()
{
- PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
+ PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
- ASSERT(m_pWidget != NULL);
+ ASSERT(m_pWidget != NULL);
- int nFlags = m_pWidget->GetFieldFlags();
+ int nFlags = m_pWidget->GetFieldFlags();
- if (nFlags & FIELDFLAG_EDIT)
- {
- cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
- }
+ if (nFlags & FIELDFLAG_EDIT)
+ {
+ cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
+ }
- if (!m_pFontMap)
- {
- m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
- m_pFontMap->Initial();
- }
+ if (!m_pFontMap)
+ {
+ m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
+ m_pFontMap->Initial();
+ }
- cp.pFontMap = m_pFontMap;
- cp.pFocusHandler = this;
+ cp.pFontMap = m_pFontMap;
+ cp.pFocusHandler = this;
- return cp;
+ 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;
+ 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)
+FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
{
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
+ return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
}
-FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView)
+FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView)
{
- if (CPWL_ComboBox * pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- int32_t nCurSel = pWnd->GetSelect();
-
- ASSERT(m_pWidget != NULL);
-
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
- {
- if (nCurSel >= 0)
- {
- return nCurSel != m_pWidget->GetSelectedIndex(0);
- }
- else
- {
- return pWnd->GetText() != m_pWidget->GetValue();
- }
- }
- else
- {
- return nCurSel != m_pWidget->GetSelectedIndex(0);
- }
- }
-
- return FALSE;
+ 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)
{
- ASSERT(m_pWidget != NULL);
-
- if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- CFX_WideString swText = pWnd->GetText();
- int32_t nCurSel = pWnd->GetSelect();
-
- //mantis:0004157
- FX_BOOL bSetValue = TRUE;
-
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
- {
- if (nCurSel >= 0)
- {
- if (swText != m_pWidget->GetOptionLabel(nCurSel))
- bSetValue = TRUE;
- else
- bSetValue = FALSE;
- }
- else
- bSetValue = TRUE;
- }
- else
- bSetValue = FALSE;
-
- CFX_WideString sOldValue;
-
-
- if (bSetValue)
- {
- sOldValue = m_pWidget->GetValue();
- 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();
-
-
- }
+ ASSERT(m_pWidget != NULL);
+
+ if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ CFX_WideString swText = pWnd->GetText();
+ int32_t nCurSel = pWnd->GetSelect();
+
+ //mantis:0004157
+ FX_BOOL bSetValue = TRUE;
+
+ if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
+ {
+ if (nCurSel >= 0)
+ {
+ if (swText != m_pWidget->GetOptionLabel(nCurSel))
+ bSetValue = TRUE;
+ else
+ bSetValue = FALSE;
+ }
+ else
+ bSetValue = TRUE;
+ }
+ else
+ bSetValue = FALSE;
+
+ CFX_WideString sOldValue;
+
+
+ if (bSetValue)
+ {
+ sOldValue = m_pWidget->GetValue();
+ 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 = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- 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 = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- fa.sValue = pEdit->GetText();
- }
- }
- break;
- case CPDF_AAction::LoseFocus:
- case CPDF_AAction::GetFocus:
- ASSERT(m_pWidget != NULL);
- fa.sValue = m_pWidget->GetValue();
- break;
- default:
- break;
- }
+ switch (type)
+ {
+ case CPDF_AAction::KeyStroke:
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ 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 = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ fa.sValue = pEdit->GetText();
+ }
+ }
+ break;
+ case CPDF_AAction::LoseFocus:
+ case CPDF_AAction::GetFocus:
+ ASSERT(m_pWidget != NULL);
+ fa.sValue = m_pWidget->GetValue();
+ break;
+ default:
+ break;
+ }
}
void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa)
+ const PDFSDK_FieldAction& fa)
{
- switch (type)
- {
- case CPDF_AAction::KeyStroke:
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
- pEdit->ReplaceSel(fa.sChange.c_str());
- }
- }
- break;
- default:
- break;
- }
+ switch (type)
+ {
+ case CPDF_AAction::KeyStroke:
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ 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)
+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;
+ 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 != NULL);
-
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
- {
- m_State.nIndex = pComboBox->GetSelect();
-
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- pEdit->GetSel(m_State.nStart, m_State.nEnd);
- m_State.sValue = pEdit->GetText();
- }
- }
+ ASSERT(pPageView != NULL);
+
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ m_State.nIndex = pComboBox->GetSelect();
+
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ pEdit->GetSel(m_State.nStart, m_State.nEnd);
+ m_State.sValue = pEdit->GetText();
+ }
+ }
}
void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView)
{
- ASSERT(pPageView != NULL);
-
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE))
- {
- if (m_State.nIndex >= 0)
- pComboBox->SetSelect(m_State.nIndex);
- else
- {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
- {
- pEdit->SetText(m_State.sValue.c_str());
- pEdit->SetSel(m_State.nStart, m_State.nEnd);
- }
- }
- }
+ ASSERT(pPageView != NULL);
+
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, TRUE))
+ {
+ if (m_State.nIndex >= 0)
+ pComboBox->SetSelect(m_State.nIndex);
+ else
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ 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);
+ if (bRestoreValue)
+ SaveState(pPageView);
- DestroyPDFWindow(pPageView);
+ DestroyPDFWindow(pPageView);
- CPWL_Wnd* pRet = NULL;
+ CPWL_Wnd* pRet = NULL;
- if (bRestoreValue)
- {
- RestoreState(pPageView);
- pRet = GetPDFWindow(pPageView, FALSE);
- }
- else
- pRet = GetPDFWindow(pPageView, TRUE);
+ if (bRestoreValue)
+ {
+ RestoreState(pPageView);
+ pRet = GetPDFWindow(pPageView, FALSE);
+ }
+ else
+ pRet = GetPDFWindow(pPageView, TRUE);
- m_pWidget->UpdateField();
+ m_pWidget->UpdateField();
- return pRet;
+ return pRet;
}
void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag)
{
- ASSERT(m_pWidget != NULL);
-
- int nFlags = m_pWidget->GetFieldFlags();
-
- if (nFlags & FIELDFLAG_COMMITONSELCHANGE)
- {
- if (m_bValid)
- {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView != NULL);
-
- if (CommitData(pPageView, nFlag))
- {
- DestroyPDFWindow(pPageView);
- m_bValid = FALSE;
- }
- }
- }
+ ASSERT(m_pWidget != NULL);
+
+ int nFlags = m_pWidget->GetFieldFlags();
+
+ if (nFlags & FIELDFLAG_COMMITONSELCHANGE)
+ {
+ if (m_bValid)
+ {
+ CPDFSDK_PageView* pPageView = GetCurPageView();
+ ASSERT(pPageView != NULL);
+
+ if (CommitData(pPageView, nFlag))
+ {
+ DestroyPDFWindow(pPageView);
+ m_bValid = FALSE;
+ }
+ }
+ }
}
void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd)
{
- ASSERT(m_pApp != NULL);
+ ASSERT(m_pApp != NULL);
- ASSERT(pWnd != NULL);
+ ASSERT(pWnd != NULL);
- if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT)
- {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCharSet(134);
- pEdit->SetCodePage(936);
+ 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->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);
- }
+ pEdit->SetEditNotify(this);
+ }
}
void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd)
{
- ASSERT(m_pApp != NULL);
+ ASSERT(m_pApp != NULL);
}
-FX_BOOL CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument)
{
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument != NULL);
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument)
{
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument != NULL);
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument)
{
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument != NULL);
- return FALSE;
+ return FALSE;
}
void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit)
{
- ASSERT(pEdit != NULL);
+ ASSERT(pEdit != NULL);
}
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;
+ 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_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index cd4b45b062..7ce811e85b 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -13,7 +13,7 @@
#include "../../include/formfiller/FFL_RadioButton.h"
#include "../../include/formfiller/FFL_TextField.h"
-#define FFL_MAXLISTBOXHEIGHT 140.0f
+#define FFL_MAXLISTBOXHEIGHT 140.0f
// HHOOK CFFL_IFormFiller::m_hookSheet = NULL;
// MSG CFFL_IFormFiller::g_Msg;
@@ -21,8 +21,8 @@
/* ----------------------------- CFFL_IFormFiller ----------------------------- */
CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) :
- m_pApp(pApp),
- m_bNotifying(FALSE)
+ m_pApp(pApp),
+ m_bNotifying(FALSE)
{
}
@@ -33,554 +33,531 @@ CFFL_IFormFiller::~CFFL_IFormFiller()
m_Maps.clear();
}
-FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point)
+FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point)
{
- CPDF_Rect rc = pAnnot->GetRect();
- if(rc.Contains(point.x, point.y))
- return TRUE;
- return FALSE;
+ CPDF_Rect 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);
- }
- else
- {
- ASSERT(pPageView != NULL);
- ASSERT(pAnnot != NULL);
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ return pFormFiller->GetViewBBox(pPageView, pAnnot);
- CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
- ASSERT(pPDFAnnot != NULL);
+ ASSERT(pPageView != NULL);
- CPDF_Rect rcAnnot;
- pPDFAnnot->GetRect(rcAnnot);
+ CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
+ CPDF_Rect rcAnnot;
+ pPDFAnnot->GetRect(rcAnnot);
-// CRect rcWin;
-// pPageView->DocToWindow(rcAnnot, rcWin);
- CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot,1);
-// rcWin.InflateRect(1, 1);
-
- return rcWin.GetOutterRect();
- }
+ CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1);
+ return rcWin.GetOutterRect();
}
void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow,*/ FX_DWORD dwFlags)
-{
- ASSERT(pPageView != NULL);
- 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)
- {
- CPDF_Rect 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);
- }
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ /*const CRect& rcWindow,*/ FX_DWORD dwFlags)
+{
+ ASSERT(pPageView != NULL);
+ 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)
+ {
+ CPDF_Rect 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);
- }
+ 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);
- }
+ 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);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ pFormFiller->OnDelete(pAnnot);
+ }
- UnRegisterFormFiller(pAnnot);
+ UnRegisterFormFiller(pAnnot);
}
void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (!m_bNotifying)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::CursorEnter))
- {
- m_bNotifying = TRUE;
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (pWidget->GetAAction(CPDF_AAction::CursorEnter))
+ {
+ m_bNotifying = TRUE;
- int nValueAge = pWidget->GetValueAge();
+ int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
+ pWidget->ClearAppModified();
- ASSERT(pPageView != NULL);
+ ASSERT(pPageView != NULL);
- 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;
+ 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 ( !IsValidAnnot(pPageView, pAnnot) ) return;
+ //if ( !IsValidAnnot(pPageView, pAnnot) ) return;
- if (pWidget->IsAppModified())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, pWidget->GetValueAge() == nValueAge);
- }
- }
- }
- }
+ 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);
- }
+ 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 != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (pWidget->GetAAction(CPDF_AAction::CursorExit))
+ {
+ m_bNotifying = TRUE;
+ pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
+ pWidget->ClearAppModified();
- if (!m_bNotifying)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::CursorExit))
- {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
+ ASSERT(pPageView != NULL);
- ASSERT(pPageView != NULL);
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- 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;
+ pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView);
+ m_bNotifying = FALSE;
- //if (!IsValidAnnot(pPageView, pAnnot)) return;
+ //if (!IsValidAnnot(pPageView, pAnnot)) return;
- if (pWidget->IsAppModified())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
+ 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);
- }
+ 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 CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ 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))
- {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (Annot_HitTest(pPageView, pAnnot, point) && pWidget->GetAAction(CPDF_AAction::ButtonDown))
+ {
+ m_bNotifying = TRUE;
+ pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
+ pWidget->ClearAppModified();
- ASSERT(pPageView != NULL);
+ ASSERT(pPageView != NULL);
- 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;
+ 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 (!IsValidAnnot(pPageView, pAnnot)) return TRUE;
- if (pWidget->IsAppModified())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
+ 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);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& 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;
- }
+ 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;
+ FX_BOOL bRet = FALSE;
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
- }
+ 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;
- }
- return bRet;
+ if (pDocument->GetFocusAnnot() == pAnnot)
+ {
+ FX_BOOL bExit = FALSE;
+ FX_BOOL bReset = FALSE;
+ OnButtonUp(pWidget, pPageView, bReset, bExit,nFlags);
+ if (bExit) return TRUE;
+ }
+ return bRet;
}
void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag)
{
- ASSERT(pWidget != NULL);
+ ASSERT(pWidget != NULL);
- if (!m_bNotifying)
- {
- if (pWidget->GetAAction(CPDF_AAction::ButtonUp))
- {
- m_bNotifying = TRUE;
- int nAge = pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
+ if (!m_bNotifying)
+ {
+ if (pWidget->GetAAction(CPDF_AAction::ButtonUp))
+ {
+ m_bNotifying = TRUE;
+ int nAge = pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
- ASSERT(pPageView != NULL);
-// CReader_DocView* pDocView = pPageView->GetDocView();
-// ASSERT(pDocView != NULL);
+ ASSERT(pPageView != NULL);
+// CReader_DocView* pDocView = pPageView->GetDocView();
+// ASSERT(pDocView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+ 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;
+ pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView);
+ m_bNotifying = FALSE;
- if (!IsValidAnnot(pPageView, pWidget))
- {
- bExit = TRUE;
- return;
- }
+ if (!IsValidAnnot(pPageView, pWidget))
+ {
+ bExit = TRUE;
+ return;
+ }
- if (nAge != pWidget->GetAppearanceAge())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
- }
+ if (nAge != pWidget->GetAppearanceAge())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
- bReset = TRUE;
- }
- }
- }
+ bReset = TRUE;
+ }
+ }
+ }
}
-FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- //change cursor
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
- {
- return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
- }
+ //change cursor
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
+ {
+ return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags)
+FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
+FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (nChar == FWL_VKEY_Tab) return TRUE;
+ 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);
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ return pFormFiller->OnChar(pAnnot, nChar, nFlags);
- return FALSE;
+ 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))
- {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
-
-
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
- ASSERT(pPageView != NULL);
-
- 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 (!IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pAnnot)) return FALSE;
-
- if (pWidget->IsAppModified())
- {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
- {
- pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
+ if (!pAnnot)
+ return FALSE;
+
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (pWidget->GetAAction(CPDF_AAction::GetFocus))
+ {
+ m_bNotifying = TRUE;
+ pWidget->GetAppearanceAge();
+
+ int nValueAge = pWidget->GetValueAge();
+ pWidget->ClearAppModified();
+
+ CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+ ASSERT(pPageView != NULL);
+
+ 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))
- {
- if (pFormFiller->OnSetFocus(pAnnot, nFlag))
- {
- return TRUE;
- }
- else
- return FALSE;
- }
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
+ return pFormFiller->OnSetFocus(pAnnot, nFlag);
- return TRUE;
+ return TRUE;
}
-FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
+FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
{
- if(!pAnnot) return FALSE;
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ if(!pAnnot) return FALSE;
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- {
- if (pFormFiller->OnKillFocus(pAnnot, nFlag))
- {
- if (!m_bNotifying)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::LoseFocus))
- {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+ {
+ if (pFormFiller->OnKillFocus(pAnnot, nFlag))
+ {
+ if (!m_bNotifying)
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (pWidget->GetAAction(CPDF_AAction::LoseFocus))
+ {
+ m_bNotifying = TRUE;
+ pWidget->ClearAppModified();
- CPDFSDK_PageView* pPageView = pWidget->GetPageView();
- ASSERT(pPageView != NULL);
+ CPDFSDK_PageView* pPageView = pWidget->GetPageView();
+ ASSERT(pPageView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);
+ pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);
- pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView);
- m_bNotifying = FALSE;
+ pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView);
+ m_bNotifying = FALSE;
- }
- }
- }
- else
- return FALSE;
- }
+ }
+ }
+ }
+ else
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget)
+FX_BOOL CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget)
{
- return pWidget->IsVisible();
+ return pWidget->IsVisible();
}
-FX_BOOL CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget)
+FX_BOOL CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget)
{
- ASSERT(pWidget != NULL);
+ ASSERT(pWidget != NULL);
- int nFieldFlags = pWidget->GetFieldFlags();
+ int nFieldFlags = pWidget->GetFieldFlags();
- return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;
+ return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;
}
-FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget)
+FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget)
{
- ASSERT(pWidget != NULL);
+ ASSERT(pWidget != NULL);
- if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return TRUE;
- else
- {
- CPDF_Page* pPage = pWidget->GetPDFPage();
- ASSERT(pPage != NULL);
+ if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
+ return TRUE;
+ else
+ {
+ CPDF_Page* pPage = pWidget->GetPDFPage();
+ ASSERT(pPage != NULL);
- CPDF_Document* pDocument = pPage->m_pDocument;
- ASSERT(pDocument != NULL);
+ CPDF_Document* pDocument = pPage->m_pDocument;
+ ASSERT(pDocument != NULL);
- FX_DWORD dwPermissions = pDocument->GetUserPermissions();
- return (dwPermissions&FPDFPERM_FILL_FORM) ||
- (dwPermissions&FPDFPERM_ANNOT_FORM) ||
- (dwPermissions&FPDFPERM_MODIFY);
- }
- return TRUE;
+ FX_DWORD dwPermissions = pDocument->GetUserPermissions();
+ return (dwPermissions&FPDFPERM_FILL_FORM) ||
+ (dwPermissions&FPDFPERM_ANNOT_FORM) ||
+ (dwPermissions&FPDFPERM_MODIFY);
+ }
+ return TRUE;
}
CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister)
@@ -629,10 +606,10 @@ CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL
void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot)
{
- if ( pAnnot != NULL )
- {
- UnRegisterFormFiller( pAnnot );
- }
+ if ( pAnnot != NULL )
+ {
+ UnRegisterFormFiller( pAnnot );
+ }
}
void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot)
@@ -647,330 +624,330 @@ void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot)
void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, int32_t & nRet, FX_FLOAT & fPopupRet)
{
- ASSERT(pPrivateData != NULL);
-
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
-
-
-
-
- CPDF_Rect rcPageView(0,0,0,0);
- rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth();
- rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight();
- rcPageView.Normalize();
-
-
- ASSERT(pData->pWidget != NULL);
- CPDF_Rect 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;
+ ASSERT(pPrivateData != NULL);
+
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+
+
+
+
+ CPDF_Rect rcPageView(0,0,0,0);
+ rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth();
+ rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight();
+ rcPageView.Normalize();
+
+
+ ASSERT(pData->pWidget != NULL);
+ CPDF_Rect 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)
- {
- ASSERT(pWidget != NULL);
- if (pWidget->GetAAction(CPDF_AAction::KeyStroke))
- {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
+ if (!m_bNotifying)
+ {
+ ASSERT(pWidget != NULL);
+ if (pWidget->GetAAction(CPDF_AAction::KeyStroke))
+ {
+ m_bNotifying = TRUE;
+ pWidget->ClearAppModified();
- ASSERT(pPageView != NULL);
+ ASSERT(pPageView != NULL);
- 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;
+ 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);
- ASSERT(pFormFiller != NULL);
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
+ ASSERT(pFormFiller != NULL);
- pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);
- pFormFiller->SaveState(pPageView);
+ pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);
+ pFormFiller->SaveState(pPageView);
- PDFSDK_FieldAction faOld = fa;
- pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView);
+ PDFSDK_FieldAction faOld = fa;
+ pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView);
- bRC = fa.bRC;
-// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+ bRC = fa.bRC;
+// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
- m_bNotifying = FALSE;
- }
- }
+ 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)
- {
- ASSERT(pWidget != NULL);
- if (pWidget->GetAAction(CPDF_AAction::Validate))
- {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
+ if (!m_bNotifying)
+ {
+ ASSERT(pWidget != NULL);
+ if (pWidget->GetAAction(CPDF_AAction::Validate))
+ {
+ m_bNotifying = TRUE;
+ pWidget->ClearAppModified();
- ASSERT(pPageView != NULL);
-// CReader_DocView* pDocView = pPageView->GetDocView();
-// ASSERT(pDocView != NULL);
+ ASSERT(pPageView != NULL);
+// CReader_DocView* pDocView = pPageView->GetDocView();
+// ASSERT(pDocView != NULL);
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- fa.bKeyDown = TRUE;
- fa.bRC = TRUE;
+ 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);
- ASSERT(pFormFiller != NULL);
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
+ ASSERT(pFormFiller != NULL);
- pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);
- pFormFiller->SaveState(pPageView);
+ pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);
+ pFormFiller->SaveState(pPageView);
- PDFSDK_FieldAction faOld = fa;
- pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView);
+ PDFSDK_FieldAction faOld = fa;
+ pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView);
- bRC = fa.bRC;
-// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+ bRC = fa.bRC;
+// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
- m_bNotifying = FALSE;
- }
- }
+ m_bNotifying = FALSE;
+ }
+ }
}
void CFFL_IFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag)
{
- if (!m_bNotifying)
- {
- ASSERT(pWidget != NULL);
- ASSERT(pPageView != NULL);
-// CReader_DocView* pDocView = pPageView->GetDocView();
-// ASSERT(pDocView != NULL);
- CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
- ASSERT(pDocument != NULL);
+ if (!m_bNotifying)
+ {
+ ASSERT(pWidget != NULL);
+ ASSERT(pPageView != NULL);
+// CReader_DocView* pDocView = pPageView->GetDocView();
+// ASSERT(pDocView != NULL);
+ CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+ ASSERT(pDocument != NULL);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- pInterForm->OnCalculate(pWidget->GetFormField());
+ pInterForm->OnCalculate(pWidget->GetFormField());
-// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
- m_bNotifying = FALSE;
- }
+ m_bNotifying = FALSE;
+ }
}
void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag)
{
- if (!m_bNotifying)
- {
- ASSERT(pWidget != NULL);
- ASSERT(pPageView != NULL);
-// CReader_DocView* pDocView = pPageView->GetDocView();
-// ASSERT(pDocView != NULL);
- CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
- ASSERT(pDocument != NULL);
+ if (!m_bNotifying)
+ {
+ ASSERT(pWidget != NULL);
+ ASSERT(pPageView != NULL);
+// CReader_DocView* pDocView = pPageView->GetDocView();
+// ASSERT(pDocView != NULL);
+ CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+ ASSERT(pDocument != NULL);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ ASSERT(pInterForm != NULL);
- FX_BOOL bFormated = FALSE;
- CFX_WideString sValue = pInterForm->OnFormat(pWidget->GetFormField(), bFormated);
+ FX_BOOL bFormated = FALSE;
+ CFX_WideString sValue = pInterForm->OnFormat(pWidget->GetFormField(), bFormated);
-// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+// bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
- if (bExit) return;
+ if (bExit) return;
- if (bFormated)
- {
- pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_str(), TRUE);
- pInterForm->UpdateField(pWidget->GetFormField());
- }
+ if (bFormated)
+ {
+ pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_str(), TRUE);
+ pInterForm->UpdateField(pWidget->GetFormField());
+ }
- m_bNotifying = FALSE;
- }
+ m_bNotifying = FALSE;
+ }
}
-FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)
+FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)
{
- ASSERT(pPageView != NULL);
- ASSERT(pAnnot != NULL);
+ ASSERT(pPageView != NULL);
+ ASSERT(pAnnot != NULL);
- if(pPageView)
- return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
- else
- return FALSE;
+ if(pPageView)
+ return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
+ else
+ return FALSE;
}
void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode,
- CFX_WideString & strChange, const CFX_WideString& strChangeEx,
- int nSelStart, int nSelEnd,
- FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag)
-{
- ASSERT(pPrivateData != NULL);
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
- ASSERT(pData->pWidget != NULL);
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
- ASSERT(pFormFiller != NULL);
-
- if (!m_bNotifying)
- {
- if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke))
- {
- m_bNotifying = TRUE;
- int nAge = pData->pWidget->GetAppearanceAge();
- int nValueAge = pData->pWidget->GetValueAge();
-
- ASSERT(pData->pPageView != NULL);
- 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;
- }
- }
-}
-
-void CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit,FX_DWORD nFlag)
-{
- ASSERT(pPrivateData != NULL);
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
- ASSERT(pData->pWidget != NULL);
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
- ASSERT(pFormFiller != NULL);
-
- if (!bEditOrList)
- pFormFiller->OnKeyStroke(bExit);
+ CFX_WideString & strChange, const CFX_WideString& strChangeEx,
+ int nSelStart, int nSelEnd,
+ FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag)
+{
+ ASSERT(pPrivateData != NULL);
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+ ASSERT(pData->pWidget != NULL);
+
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
+ ASSERT(pFormFiller != NULL);
+
+ if (!m_bNotifying)
+ {
+ if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke))
+ {
+ m_bNotifying = TRUE;
+ int nAge = pData->pWidget->GetAppearanceAge();
+ int nValueAge = pData->pWidget->GetValueAge();
+
+ ASSERT(pData->pPageView != NULL);
+ 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;
+ }
+ }
+}
+
+void CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit,FX_DWORD nFlag)
+{
+ ASSERT(pPrivateData != NULL);
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+ ASSERT(pData->pWidget != NULL);
+
+ CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
+ ASSERT(pFormFiller != NULL);
+
+ if (!bEditOrList)
+ pFormFiller->OnKeyStroke(bExit);
}
diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp
index a5be60ed4e..a4b87263ed 100644
--- a/fpdfsdk/src/formfiller/FFL_TextField.cpp
+++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp
@@ -10,11 +10,11 @@
/* ------------------------------- CFFL_TextField ------------------------------- */
CFFL_TextField::CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) :
- CFFL_FormFiller(pApp, pAnnot),
- m_pFontMap(NULL)//,
- //m_pSpellCheck(NULL)
+ CFFL_FormFiller(pApp, pAnnot),
+ m_pFontMap(NULL)//,
+ //m_pSpellCheck(NULL)
{
- m_State.nStart = m_State.nEnd = 0;
+ m_State.nStart = m_State.nEnd = 0;
}
CFFL_TextField::~CFFL_TextField()
@@ -24,316 +24,313 @@ CFFL_TextField::~CFFL_TextField()
PWL_CREATEPARAM CFFL_TextField::GetCreateParam()
{
- PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
-
- ASSERT(m_pWidget != NULL);
- 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());
- m_pFontMap->Initial();
- }
- cp.pFontMap = m_pFontMap;
- cp.pFocusHandler = this;
-
- return cp;
+ PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
+
+ ASSERT(m_pWidget != NULL);
+ 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());
+ m_pFontMap->Initial();
+ }
+ 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);
-
-
-
- ASSERT(m_pApp != NULL);
- CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
- pWnd->SetFillerNotify(pIFormFiller);
-
- ASSERT(m_pWidget != NULL);
- 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;
+ CPWL_Edit * pWnd = new CPWL_Edit();
+ pWnd->AttachFFLData(this);
+ pWnd->Create(cp);
+
+
+
+ ASSERT(m_pApp != NULL);
+ CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
+ pWnd->SetFillerNotify(pIFormFiller);
+
+ ASSERT(m_pWidget != NULL);
+ 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)
+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 != NULL);
- m_bValid = !m_bValid;
- CPDF_Rect rcAnnot = pAnnot->GetRect();
- m_pApp->FFI_Invalidate(pAnnot->GetPDFPage(), 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;
- }
- else
- {
- return FALSE;
- }
- }
- }
- break;
- case FWL_VKEY_Escape:
- {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView != NULL);
- EscapeFiller(pPageView,TRUE);
- return TRUE;
- }
- }
-
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
+ switch (nChar)
+ {
+ case FWL_VKEY_Return:
+ if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE))
+ {
+ CPDFSDK_PageView* pPageView = GetCurPageView();
+ ASSERT(pPageView != NULL);
+ m_bValid = !m_bValid;
+ CPDF_Rect rcAnnot = pAnnot->GetRect();
+ m_pApp->FFI_Invalidate(pAnnot->GetPDFPage(), 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 != NULL);
+ EscapeFiller(pPageView,TRUE);
+ return TRUE;
+ }
+ }
+
+ return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
}
-FX_BOOL CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView)
+FX_BOOL CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView)
{
- ASSERT(m_pWidget != NULL);
+ ASSERT(m_pWidget != NULL);
- if (CPWL_Edit * pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- return pEdit->GetText() != m_pWidget->GetValue();
+ if (CPWL_Edit * pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
+ return pEdit->GetText() != m_pWidget->GetValue();
- return FALSE;
+ return FALSE;
}
void CFFL_TextField::SaveData(CPDFSDK_PageView* pPageView)
{
- ASSERT(m_pWidget != NULL);
-
- 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();
- }
+ ASSERT(m_pWidget != NULL);
+
+ 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)
+ 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:
- ASSERT(m_pWidget != NULL);
- fa.sValue = m_pWidget->GetValue();
- break;
- default:
- break;
- }
+ 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:
+ ASSERT(m_pWidget != NULL);
+ fa.sValue = m_pWidget->GetValue();
+ break;
+ default:
+ break;
+ }
}
void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa)
+ 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;
- }
+ 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)
+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;
+ 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 != NULL);
+ ASSERT(pPageView != NULL);
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- {
- pWnd->GetSel(m_State.nStart, m_State.nEnd);
- m_State.sValue = pWnd->GetText();
- }
+ 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 != NULL);
+ ASSERT(pPageView != NULL);
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE))
- {
- pWnd->SetText(m_State.sValue.c_str());
- pWnd->SetSel(m_State.nStart, m_State.nEnd);
- }
+ 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);
+ if (bRestoreValue)
+ SaveState(pPageView);
- DestroyPDFWindow(pPageView);
+ DestroyPDFWindow(pPageView);
- CPWL_Wnd* pRet = NULL;
+ CPWL_Wnd* pRet = NULL;
- if (bRestoreValue)
- {
- RestoreState(pPageView);
- pRet = GetPDFWindow(pPageView, FALSE);
- }
- else
- pRet = GetPDFWindow(pPageView, TRUE);
+ if (bRestoreValue)
+ {
+ RestoreState(pPageView);
+ pRet = GetPDFWindow(pPageView, FALSE);
+ }
+ else
+ pRet = GetPDFWindow(pPageView, TRUE);
- m_pWidget->UpdateField();
+ m_pWidget->UpdateField();
- return pRet;
+ return pRet;
}
void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd)
{
- ASSERT(m_pApp != NULL);
-
- ASSERT(pWnd != NULL);
-
- 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);
- //pUndo->BeginEdit(pDocument);
- }
+ ASSERT(m_pApp != NULL);
+
+ ASSERT(pWnd != NULL);
+
+ 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);
+ //pUndo->BeginEdit(pDocument);
+ }
}
void CFFL_TextField::OnKillFocus(CPWL_Wnd* pWnd)
@@ -341,19 +338,19 @@ void CFFL_TextField::OnKillFocus(CPWL_Wnd* pWnd)
}
-FX_BOOL CFFL_TextField::CanCopy(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_TextField::CanCopy(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_TextField::CanCut(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_TextField::CanPaste(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_TextField::CanPaste(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
void CFFL_TextField::OnAddUndo(CPWL_Edit* pEdit)