| Index: fpdfsdk/src/fsdk_annothandler.cpp
|
| diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
|
| index ee06091bff1f3f1fbf90eebfbe8147cbd1ad5d5b..aa383844b4338a287cd2afcee7683397da0e5daa 100644
|
| --- a/fpdfsdk/src/fsdk_annothandler.cpp
|
| +++ b/fpdfsdk/src/fsdk_annothandler.cpp
|
| @@ -6,6 +6,10 @@
|
|
|
| #include <algorithm>
|
|
|
| +#ifdef PDF_ENABLE_XFA
|
| +#include "../include/fpdfxfa/fpdfxfa_doc.h"
|
| +#include "../include/fpdfxfa/fpdfxfa_util.h"
|
| +#endif
|
| #include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
|
| #include "fpdfsdk/include/fsdk_annothandler.h"
|
| #include "fpdfsdk/include/fsdk_define.h"
|
| @@ -17,6 +21,12 @@ CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) {
|
| CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp);
|
| pHandler->SetFormFiller(m_pApp->GetIFormFiller());
|
| RegisterAnnotHandler(pHandler);
|
| +#ifdef PDF_ENABLE_XFA
|
| +
|
| + CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler =
|
| + new CPDFSDK_XFAAnnotHandler(m_pApp);
|
| + RegisterAnnotHandler(pXFAAnnotHandler);
|
| +#endif
|
| }
|
|
|
| CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {
|
| @@ -60,6 +70,21 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot,
|
| return new CPDFSDK_BAAnnot(pAnnot, pPageView);
|
| }
|
|
|
| +#ifdef PDF_ENABLE_XFA
|
| +CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(IXFA_Widget* pAnnot,
|
| + CPDFSDK_PageView* pPageView) {
|
| + ASSERT(pAnnot != NULL);
|
| + ASSERT(pPageView != NULL);
|
| +
|
| + if (IPDFSDK_AnnotHandler* pAnnotHandler =
|
| + GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) {
|
| + return pAnnotHandler->NewAnnot(pAnnot, pPageView);
|
| + }
|
| +
|
| + return NULL;
|
| +}
|
| +
|
| +#endif
|
| void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
|
| ASSERT(pAnnot != NULL);
|
|
|
| @@ -102,6 +127,10 @@ IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
|
| CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
|
| if (pPDFAnnot)
|
| return GetAnnotHandler(pPDFAnnot->GetSubType());
|
| +#ifdef PDF_ENABLE_XFA
|
| + if (pAnnot->GetXFAWidget())
|
| + return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME);
|
| +#endif
|
| return nullptr;
|
| }
|
|
|
| @@ -121,6 +150,10 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
|
| if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
|
| pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
|
| } else {
|
| +#ifdef PDF_ENABLE_XFA
|
| + if (pAnnot->IsXFAField())
|
| + return;
|
| +#endif
|
| static_cast<CPDFSDK_BAAnnot*>(pAnnot)
|
| ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
|
| }
|
| @@ -292,6 +325,23 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot,
|
| return FALSE;
|
| }
|
|
|
| +#ifdef PDF_ENABLE_XFA
|
| +FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(
|
| + CPDFSDK_Annot* pSetAnnot,
|
| + CPDFSDK_Annot* pKillAnnot) {
|
| + FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) ||
|
| + (pKillAnnot && pKillAnnot->GetXFAWidget());
|
| +
|
| + if (bXFA) {
|
| + if (IPDFSDK_AnnotHandler* pXFAAnnotHandler =
|
| + GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME))
|
| + return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot);
|
| + }
|
| +
|
| + return TRUE;
|
| +}
|
| +
|
| +#endif
|
| CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(
|
| CPDFSDK_PageView* pPageView,
|
| CPDFSDK_Annot* pAnnot) {
|
| @@ -315,8 +365,39 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView,
|
|
|
| CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
|
| FX_BOOL bNext) {
|
| +#ifndef PDF_ENABLE_XFA
|
| CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", "");
|
| return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
|
| +#else
|
| + CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView();
|
| + CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage();
|
| + if (pPage == NULL)
|
| + return NULL;
|
| + if (pPage->GetPDFPage()) { // for pdf annots.
|
| + CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), "");
|
| + CPDFSDK_Annot* pNext =
|
| + bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
|
| + return pNext;
|
| + }
|
| + // for xfa annots
|
| + IXFA_WidgetIterator* pWidgetIterator =
|
| + pPage->GetXFAPageView()->CreateWidgetIterator(
|
| + XFA_TRAVERSEWAY_Tranvalse, XFA_WIDGETFILTER_Visible |
|
| + XFA_WIDGETFILTER_Viewable |
|
| + XFA_WIDGETFILTER_Field);
|
| + if (pWidgetIterator == NULL)
|
| + return NULL;
|
| + if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget())
|
| + pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget());
|
| + IXFA_Widget* hNextFocus = NULL;
|
| + hNextFocus =
|
| + bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious();
|
| + if (hNextFocus == NULL && pSDKAnnot != NULL)
|
| + hNextFocus = pWidgetIterator->MoveToFirst();
|
| +
|
| + pWidgetIterator->Release();
|
| + return pPageView->GetAnnotByXFAWidget(hNextFocus);
|
| +#endif
|
| }
|
|
|
| FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
|
| @@ -360,6 +441,13 @@ CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot,
|
| return pWidget;
|
| }
|
|
|
| +#ifdef PDF_ENABLE_XFA
|
| +CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(IXFA_Widget* hWidget,
|
| + CPDFSDK_PageView* pPage) {
|
| + return NULL;
|
| +}
|
| +
|
| +#endif
|
| void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
|
| ASSERT(pAnnot != NULL);
|
|
|
| @@ -593,6 +681,16 @@ void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
|
| }
|
| }
|
|
|
| +#ifdef PDF_ENABLE_XFA
|
| + CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
|
| + CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
|
| + CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
|
| + if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) {
|
| + if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
|
| + pWidget->ResetAppearance(FALSE);
|
| + }
|
| +
|
| +#endif
|
| if (m_pFormFiller)
|
| m_pFormFiller->OnLoad(pAnnot);
|
| }
|
| @@ -648,6 +746,426 @@ FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
|
| return rect.Contains(point.x, point.y);
|
| }
|
|
|
| +#ifdef PDF_ENABLE_XFA
|
| +#define FWL_WGTHITTEST_Unknown 0
|
| +#define FWL_WGTHITTEST_Client 1 // arrow
|
| +#define FWL_WGTHITTEST_Titlebar 11 // caption
|
| +#define FWL_WGTHITTEST_HScrollBar 15
|
| +#define FWL_WGTHITTEST_VScrollBar 16
|
| +#define FWL_WGTHITTEST_Border 17
|
| +#define FWL_WGTHITTEST_Edit 19
|
| +#define FWL_WGTHITTEST_HyperLink 20
|
| +
|
| +CPDFSDK_XFAAnnotHandler::CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp)
|
| + : m_pApp(pApp) {}
|
| +
|
| +CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(IXFA_Widget* pAnnot,
|
| + CPDFSDK_PageView* pPage) {
|
| + CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
|
| + CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm();
|
| + CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm);
|
| + pInterForm->AddXFAMap(pAnnot, pWidget);
|
| + return pWidget;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
|
| + return pAnnot->GetXFAWidget() != NULL;
|
| +}
|
| +
|
| +void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + CFX_RenderDevice* pDevice,
|
| + CPDF_Matrix* pUser2Device,
|
| + FX_DWORD dwFlags) {
|
| +#ifdef PDF_ENABLE_XFA
|
| +
|
| + ASSERT(pPageView != NULL);
|
| + ASSERT(pAnnot != NULL);
|
| +
|
| + CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
|
| + ASSERT(pSDKDoc != NULL);
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + CFX_Graphics gs;
|
| + gs.Create(pDevice);
|
| +
|
| + CFX_Matrix mt;
|
| + mt = *(CFX_Matrix*)pUser2Device;
|
| +
|
| + FX_BOOL bIsHighlight = FALSE;
|
| + if (pSDKDoc->GetFocusAnnot() != pAnnot)
|
| + bIsHighlight = TRUE;
|
| +
|
| + pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight);
|
| +
|
| + // to do highlight and shadow
|
| +#endif // PDF_ENABLE_XFA
|
| +}
|
| +
|
| +void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
|
| + ASSERT(pAnnot != NULL);
|
| +
|
| + CPDFSDK_XFAWidget* pWidget = (CPDFSDK_XFAWidget*)pAnnot;
|
| + CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
|
| + ASSERT(pInterForm != NULL);
|
| +
|
| + pInterForm->RemoveXFAMap(pWidget->GetXFAWidget());
|
| +
|
| + delete pWidget;
|
| +}
|
| +
|
| +CPDF_Rect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot) {
|
| + ASSERT(pAnnot != NULL);
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + CFX_RectF rcBBox;
|
| +#ifdef PDF_ENABLE_XFA
|
| + XFA_ELEMENT eType =
|
| + pWidgetHandler->GetDataAcc(pAnnot->GetXFAWidget())->GetUIType();
|
| + if (eType == XFA_ELEMENT_Signature)
|
| + pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox,
|
| + XFA_WIDGETSTATUS_Visible, TRUE);
|
| + else
|
| +#endif
|
| + pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, 0);
|
| +
|
| + CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
|
| + rcBBox.top + rcBBox.height);
|
| + rcWidget.left -= 1.0f;
|
| + rcWidget.right += 1.0f;
|
| + rcWidget.bottom -= 1.0f;
|
| + rcWidget.top += 1.0f;
|
| +
|
| + return rcWidget;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
|
| + if (!pSDKDoc)
|
| + return FALSE;
|
| +
|
| + CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
|
| + if (!pDoc)
|
| + return FALSE;
|
| +
|
| + IXFA_DocView* pDocView = pDoc->GetXFADocView();
|
| + if (!pDocView)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
|
| + if (!pWidgetHandler)
|
| + return FALSE;
|
| +
|
| + FX_DWORD dwHitTest =
|
| + pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y);
|
| + return (dwHitTest != FWL_WGTHITTEST_Unknown);
|
| +}
|
| +
|
| +void CPDFSDK_XFAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlag) {
|
| + if (!pPageView || !pAnnot)
|
| + return;
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + pWidgetHandler->OnMouseEnter(pAnnot->GetXFAWidget());
|
| +}
|
| +
|
| +void CPDFSDK_XFAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlag) {
|
| + if (!pPageView || !pAnnot)
|
| + return;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + pWidgetHandler->OnMouseExit(pAnnot->GetXFAWidget());
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlags,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnLButtonDown(pAnnot->GetXFAWidget(),
|
| + GetFWLFlags(nFlags), point.x, point.y);
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlags,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnLButtonUp(pAnnot->GetXFAWidget(),
|
| + GetFWLFlags(nFlags), point.x, point.y);
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlags,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnLButtonDblClk(pAnnot->GetXFAWidget(),
|
| + GetFWLFlags(nFlags), point.x, point.y);
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlags,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnMouseMove(pAnnot->GetXFAWidget(),
|
| + GetFWLFlags(nFlags), point.x, point.y);
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlags,
|
| + short zDelta,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnMouseWheel(
|
| + pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y);
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlags,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnRButtonDown(pAnnot->GetXFAWidget(),
|
| + GetFWLFlags(nFlags), point.x, point.y);
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlags,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnRButtonUp(pAnnot->GetXFAWidget(),
|
| + GetFWLFlags(nFlags), point.x, point.y);
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
|
| + CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlags,
|
| + const CPDF_Point& point) {
|
| + if (!pPageView || !pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnRButtonDblClk(pAnnot->GetXFAWidget(),
|
| + GetFWLFlags(nFlags), point.x, point.y);
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nChar,
|
| + FX_DWORD nFlags) {
|
| + if (!pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar,
|
| + GetFWLFlags(nFlags));
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
|
| + int nKeyCode,
|
| + int nFlag) {
|
| + if (!pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode,
|
| + GetFWLFlags(nFlag));
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
|
| + int nKeyCode,
|
| + int nFlag) {
|
| + if (!pAnnot)
|
| + return FALSE;
|
| +
|
| + IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
|
| + ASSERT(pWidgetHandler != NULL);
|
| +
|
| + FX_BOOL bRet = FALSE;
|
| + bRet = pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode,
|
| + GetFWLFlags(nFlag));
|
| +
|
| + return bRet;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlag) {
|
| + return TRUE;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot,
|
| + FX_DWORD nFlag) {
|
| + return TRUE;
|
| +}
|
| +
|
| +FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot,
|
| + CPDFSDK_Annot* pNewAnnot) {
|
| + IXFA_WidgetHandler* pWidgetHandler = NULL;
|
| +
|
| + if (pOldAnnot)
|
| + pWidgetHandler = GetXFAWidgetHandler(pOldAnnot);
|
| + else if (pNewAnnot)
|
| + pWidgetHandler = GetXFAWidgetHandler(pNewAnnot);
|
| +
|
| + if (pWidgetHandler) {
|
| + FX_BOOL bRet = TRUE;
|
| + IXFA_Widget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : NULL;
|
| + if (hWidget) {
|
| + IXFA_PageView* pXFAPageView = pWidgetHandler->GetPageView(hWidget);
|
| + if (pXFAPageView) {
|
| + bRet = pXFAPageView->GetDocView()->SetFocus(hWidget);
|
| + if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget)
|
| + bRet = TRUE;
|
| + }
|
| + }
|
| + return bRet;
|
| + }
|
| +
|
| + return TRUE;
|
| +}
|
| +
|
| +IXFA_WidgetHandler* CPDFSDK_XFAAnnotHandler::GetXFAWidgetHandler(
|
| + CPDFSDK_Annot* pAnnot) {
|
| + if (!pAnnot)
|
| + return NULL;
|
| +
|
| + CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
|
| + if (!pPageView)
|
| + return NULL;
|
| +
|
| + CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
|
| + if (!pSDKDoc)
|
| + return NULL;
|
| +
|
| + CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
|
| + if (!pDoc)
|
| + return NULL;
|
| +
|
| + IXFA_DocView* pDocView = pDoc->GetXFADocView();
|
| + if (!pDocView)
|
| + return NULL;
|
| +
|
| + return pDocView->GetWidgetHandler();
|
| +}
|
| +
|
| +#define FWL_KEYFLAG_Ctrl (1 << 0)
|
| +#define FWL_KEYFLAG_Alt (1 << 1)
|
| +#define FWL_KEYFLAG_Shift (1 << 2)
|
| +#define FWL_KEYFLAG_LButton (1 << 3)
|
| +#define FWL_KEYFLAG_RButton (1 << 4)
|
| +#define FWL_KEYFLAG_MButton (1 << 5)
|
| +
|
| +FX_DWORD CPDFSDK_XFAAnnotHandler::GetFWLFlags(FX_DWORD dwFlag) {
|
| + FX_DWORD dwFWLFlag = 0;
|
| +
|
| + if (dwFlag & FWL_EVENTFLAG_ControlKey)
|
| + dwFWLFlag |= FWL_KEYFLAG_Ctrl;
|
| + if (dwFlag & FWL_EVENTFLAG_LeftButtonDown)
|
| + dwFWLFlag |= FWL_KEYFLAG_LButton;
|
| + if (dwFlag & FWL_EVENTFLAG_MiddleButtonDown)
|
| + dwFWLFlag |= FWL_KEYFLAG_MButton;
|
| + if (dwFlag & FWL_EVENTFLAG_RightButtonDown)
|
| + dwFWLFlag |= FWL_KEYFLAG_RButton;
|
| + if (dwFlag & FWL_EVENTFLAG_ShiftKey)
|
| + dwFWLFlag |= FWL_KEYFLAG_Shift;
|
| + if (dwFlag & FWL_EVENTFLAG_AltKey)
|
| + dwFWLFlag |= FWL_KEYFLAG_Alt;
|
| +
|
| + return dwFWLFlag;
|
| +}
|
| +
|
| +#endif
|
| CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView,
|
| bool bReverse)
|
| : m_bReverse(bReverse), m_pos(0) {
|
|
|