DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nChar, int modifier) { CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); if (!pPageView) return FALSE; return pPageView->OnChar(nChar, modifier); }
DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nKeyCode, int modifier) { CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); if (!pPageView) return false; return pPageView->OnKeyUp(nKeyCode, modifier); }
DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) { CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); if (!pPageView) return FALSE; CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); return pPageView->OnRButtonUp(pt, modifier); }
DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle) { if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) pPageView->SetValid(TRUE); }
DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, int rotate, int flags) { if (!hHandle) return; UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); if (!pPage) return; #ifndef PDF_ENABLE_XFA CPDF_RenderOptions options; if (flags & FPDF_LCD_TEXT) options.m_Flags |= RENDER_CLEARTYPE; else options.m_Flags &= ~RENDER_CLEARTYPE; // Grayscale output if (flags & FPDF_GRAYSCALE) { options.m_ColorMode = RENDER_COLOR_GRAY; options.m_ForeColor = 0; options.m_BackColor = 0xffffff; } options.m_AddFlags = flags >> 8; options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument); #else // PDF_ENABLE_XFA CPDFXFA_Document* pDocument = pPage->GetDocument(); if (!pDocument) return; CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); if (!pPDFDoc) return; CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); if (!pFXDoc) return; #endif // PDF_ENABLE_XFA CFX_Matrix matrix; pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y); #ifdef _SKIA_SUPPORT_ std::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice); #else std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice); #endif pDevice->Attach((CFX_DIBitmap*)bitmap); pDevice->SaveState(); pDevice->SetClip_Rect(clip); #ifndef PDF_ENABLE_XFA if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); #else // PDF_ENABLE_XFA CPDF_RenderOptions options; if (flags & FPDF_LCD_TEXT) options.m_Flags |= RENDER_CLEARTYPE; else options.m_Flags &= ~RENDER_CLEARTYPE; // Grayscale output if (flags & FPDF_GRAYSCALE) { options.m_ColorMode = RENDER_COLOR_GRAY; options.m_ForeColor = 0; options.m_BackColor = 0xffffff; } options.m_AddFlags = flags >> 8; options.m_pOCContext = new CPDF_OCContext(pPDFDoc); if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage)) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); #endif // PDF_ENABLE_XFA pDevice->RestoreState(); delete options.m_pOCContext; #ifdef PDF_ENABLE_XFA options.m_pOCContext = NULL; #endif // PDF_ENABLE_XFA }