diff options
Diffstat (limited to 'fpdfsdk/src/formfiller/FFL_IFormFiller.cpp')
-rw-r--r-- | fpdfsdk/src/formfiller/FFL_IFormFiller.cpp | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp index 61fd04a0d7..4a5a7bcd96 100644 --- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp +++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp @@ -1,7 +1,7 @@ // 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 "../../include/formfiller/FFL_FormFiller.h" @@ -20,7 +20,7 @@ /* ----------------------------- CFFL_IFormFiller ----------------------------- */ -CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) : +CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) : m_pApp(pApp), m_bNotifying(FALSE) { @@ -73,7 +73,7 @@ FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot } } -void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, +void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, /*const CRect& rcWindow,*/ FX_DWORD dwFlags) { @@ -87,9 +87,9 @@ void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_ if (pFormFiller->IsValid()) { pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); - + pAnnot->GetPDFPage(); - + CPDFSDK_Document* pDocument = m_pApp->GetCurrentDoc(); ASSERT(pDocument != NULL); @@ -100,23 +100,23 @@ void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_ 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.SetDashCount(1); gsd.m_DashArray[0] = 1.0f; - gsd.m_DashPhase = 0; - + gsd.m_DashPhase = 0; + gsd.m_LineWidth = 1.0f; pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255,0,0,0), FXFILL_ALTERNATE); - // ::DrawFocusRect(hDC, &rcFocus); + // ::DrawFocusRect(hDC, &rcFocus); } } @@ -133,7 +133,7 @@ void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_ { pWidget->DrawShadow(pDevice, pPageView); } - + } } @@ -167,30 +167,30 @@ void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* { 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; - + int nValueAge = pWidget->GetValueAge(); pWidget->ClearAppModified(); - + 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; - + //if ( !IsValidAnnot(pPageView, pAnnot) ) return; - + if (pWidget->IsAppModified()) { if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) @@ -200,7 +200,7 @@ void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* } } } - + if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { pFormFiller->OnMouseEnter(pPageView, pAnnot); @@ -211,7 +211,7 @@ void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* p { ASSERT(pAnnot != NULL); ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); - + if (!m_bNotifying) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; @@ -221,20 +221,20 @@ void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* p pWidget->GetAppearanceAge(); int nValueAge = pWidget->GetValueAge(); pWidget->ClearAppModified(); - + ASSERT(pPageView != NULL); - - - + + + 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 (!IsValidAnnot(pPageView, pAnnot)) return; - + if (pWidget->IsAppModified()) { if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) @@ -244,7 +244,7 @@ void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* p } } } - + if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { pFormFiller->OnMouseExit(pPageView, pAnnot); @@ -255,7 +255,7 @@ FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Ann { ASSERT(pAnnot != NULL); ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); - + if (!m_bNotifying) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; @@ -265,19 +265,19 @@ FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Ann pWidget->GetAppearanceAge(); int nValueAge = pWidget->GetValueAge(); pWidget->ClearAppModified(); - + 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; - + if (!IsValidAnnot(pPageView, pAnnot)) return TRUE; - + if (pWidget->IsAppModified()) { if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) @@ -287,12 +287,12 @@ FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Ann } } } - + if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); } - + return FALSE; } @@ -300,13 +300,13 @@ FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot { ASSERT(pAnnot != NULL); ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); - + CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; // CReader_Page* pPage = pAnnot->GetPage(); // ASSERT(pPage != NULL); CPDFSDK_Document* pDocument = m_pApp->GetCurrentDoc(); - ASSERT(pDocument != NULL); - + ASSERT(pDocument != NULL); + switch (pWidget->GetFieldType()) { case FIELDTYPE_PUSHBUTTON: @@ -321,9 +321,9 @@ FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot pDocument->SetFocusAnnot(pAnnot); break; } - + FX_BOOL bRet = FALSE; - + if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); @@ -345,7 +345,7 @@ FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag) { ASSERT(pWidget != NULL); - + if (!m_bNotifying) { if (pWidget->GetAAction(CPDF_AAction::ButtonUp)) @@ -353,33 +353,33 @@ void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPa m_bNotifying = TRUE; int nAge = pWidget->GetAppearanceAge(); int nValueAge = pWidget->GetValueAge(); - + 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); 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; } } @@ -472,7 +472,7 @@ FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { - return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); + return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); } return FALSE; @@ -529,25 +529,25 @@ FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) 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)) @@ -557,7 +557,7 @@ FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) } } } - + if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { if (pFormFiller->OnSetFocus(pAnnot, nFlag)) @@ -587,19 +587,19 @@ FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) { m_bNotifying = TRUE; pWidget->ClearAppModified(); - + 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); - + pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa); - + pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView); m_bNotifying = FALSE; - + } } } @@ -634,16 +634,16 @@ FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) { CPDF_Page* pPage = pWidget->GetPDFPage(); ASSERT(pPage != NULL); - + CPDF_Document* pDocument = pPage->m_pDocument; ASSERT(pDocument != NULL); - + FX_DWORD dwPermissions = pDocument->GetUserPermissions(); - return (dwPermissions&FPDFPERM_FILL_FORM) || - (dwPermissions&FPDFPERM_ANNOT_FORM) || + return (dwPermissions&FPDFPERM_FILL_FORM) || + (dwPermissions&FPDFPERM_ANNOT_FORM) || (dwPermissions&FPDFPERM_MODIFY); } - return TRUE; + return TRUE; } CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister) @@ -659,7 +659,7 @@ CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL if (bRegister) { - CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; + CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; int nFieldType = pWidget->GetFieldType(); switch(nFieldType) @@ -728,7 +728,7 @@ void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; - + CPDF_Rect rcPageView(0,0,0,0); @@ -837,8 +837,8 @@ void CFFL_IFormFiller::OnSetWindowRect(void* pPrivateData, const CPDF_Rect & rcW } } -void CFFL_IFormFiller::OnKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode, CFX_WideString& strChange, - const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, +void CFFL_IFormFiller::OnKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode, CFX_WideString& strChange, + const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit) { ASSERT(pPrivateData != NULL); @@ -864,8 +864,8 @@ void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageVi ASSERT(pPageView != NULL); // CReader_DocView* pDocView = pPageView->GetDocView(); // ASSERT(pDocView != NULL); - - + + PDFSDK_FieldAction fa; fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); @@ -904,8 +904,8 @@ void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPa ASSERT(pPageView != NULL); // CReader_DocView* pDocView = pPageView->GetDocView(); // ASSERT(pDocView != NULL); - - + + PDFSDK_FieldAction fa; fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); @@ -1228,17 +1228,17 @@ void CFFL_IFormFiller::DoPaste(CPDFSDK_Document* pDocument) } void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode, - CFX_WideString & strChange, const CFX_WideString& strChangeEx, + 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 (pFormFiller->IsFieldFull(pData->pPageView)) { FX_BOOL bFullExit = FALSE; @@ -1251,7 +1251,7 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData return; } } - + if (!m_bNotifying) { if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke)) @@ -1262,7 +1262,7 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData 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); @@ -1277,7 +1277,7 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData 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)) @@ -1286,14 +1286,14 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData 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); @@ -1304,7 +1304,7 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData pFormFiller->RestoreState(pData->pPageView); bRC = FALSE; } - + if (pDocument->GetFocusAnnot() != pData->pWidget) { pFormFiller->CommitData(pData->pPageView,nFlag); @@ -1312,7 +1312,7 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData } } else - { + { if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { bExit = TRUE; @@ -1320,21 +1320,21 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData return; } } - + m_bNotifying = FALSE; } } } -void CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit,FX_DWORD nFlag) +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); } |