| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "public/fpdf_formfill.h" | 7 #include "public/fpdf_formfill.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 int size_y, | 68 int size_y, |
| 69 int rotate, | 69 int rotate, |
| 70 int flags) { | 70 int flags) { |
| 71 if (!hHandle) | 71 if (!hHandle) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); | 74 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); |
| 75 if (!pPage) | 75 if (!pPage) |
| 76 return; | 76 return; |
| 77 | 77 |
| 78 #ifndef PDF_ENABLE_XFA | 78 #ifdef PDF_ENABLE_XFA |
| 79 CPDF_RenderOptions options; | |
| 80 if (flags & FPDF_LCD_TEXT) | |
| 81 options.m_Flags |= RENDER_CLEARTYPE; | |
| 82 else | |
| 83 options.m_Flags &= ~RENDER_CLEARTYPE; | |
| 84 // Grayscale output | |
| 85 if (flags & FPDF_GRAYSCALE) { | |
| 86 options.m_ColorMode = RENDER_COLOR_GRAY; | |
| 87 options.m_ForeColor = 0; | |
| 88 options.m_BackColor = 0xffffff; | |
| 89 } | |
| 90 options.m_AddFlags = flags >> 8; | |
| 91 options.m_pOCContext = | |
| 92 new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View); | |
| 93 #else // PDF_ENABLE_XFA | |
| 94 CPDFXFA_Document* pDocument = pPage->GetDocument(); | 79 CPDFXFA_Document* pDocument = pPage->GetDocument(); |
| 95 if (!pDocument) | 80 if (!pDocument) |
| 96 return; | 81 return; |
| 97 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); | 82 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); |
| 98 if (!pPDFDoc) | 83 if (!pPDFDoc) |
| 99 return; | 84 return; |
| 100 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; | 85 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; |
| 101 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); | 86 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); |
| 102 if (!pFXDoc) | 87 if (!pFXDoc) |
| 103 return; | 88 return; |
| 104 #endif // PDF_ENABLE_XFA | 89 #endif // PDF_ENABLE_XFA |
| 105 | 90 |
| 106 CFX_Matrix matrix; | 91 CFX_Matrix matrix; |
| 107 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); | 92 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); |
| 108 | 93 |
| 109 FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y); | 94 FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y); |
| 110 | 95 |
| 111 std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice); | 96 std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice); |
| 112 #ifdef _SKIA_SUPPORT_ | 97 #ifdef _SKIA_SUPPORT_ |
| 113 pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder)); | 98 pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder)); |
| 114 #endif | 99 #endif |
| 115 pDevice->Attach(CFXBitmapFromFPDFBitmap(bitmap), false, nullptr, false); | 100 pDevice->Attach(CFXBitmapFromFPDFBitmap(bitmap), false, nullptr, false); |
| 116 pDevice->SaveState(); | 101 pDevice->SaveState(); |
| 117 pDevice->SetClip_Rect(clip); | 102 pDevice->SetClip_Rect(clip); |
| 118 | 103 |
| 119 #ifndef PDF_ENABLE_XFA | |
| 120 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) | |
| 121 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); | |
| 122 #else // PDF_ENABLE_XFA | |
| 123 CPDF_RenderOptions options; | 104 CPDF_RenderOptions options; |
| 124 if (flags & FPDF_LCD_TEXT) | 105 if (flags & FPDF_LCD_TEXT) |
| 125 options.m_Flags |= RENDER_CLEARTYPE; | 106 options.m_Flags |= RENDER_CLEARTYPE; |
| 126 else | 107 else |
| 127 options.m_Flags &= ~RENDER_CLEARTYPE; | 108 options.m_Flags &= ~RENDER_CLEARTYPE; |
| 128 | 109 |
| 129 // Grayscale output | 110 // Grayscale output |
| 130 if (flags & FPDF_GRAYSCALE) { | 111 if (flags & FPDF_GRAYSCALE) { |
| 131 options.m_ColorMode = RENDER_COLOR_GRAY; | 112 options.m_ColorMode = RENDER_COLOR_GRAY; |
| 132 options.m_ForeColor = 0; | 113 options.m_ForeColor = 0; |
| 133 options.m_BackColor = 0xffffff; | 114 options.m_BackColor = 0xffffff; |
| 134 } | 115 } |
| 135 options.m_AddFlags = flags >> 8; | 116 options.m_AddFlags = flags >> 8; |
| 117 |
| 118 #ifdef PDF_ENABLE_XFA |
| 136 options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View); | 119 options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View); |
| 137 | |
| 138 if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage, true)) | 120 if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage, true)) |
| 139 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); | 121 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); |
| 122 #else // PDF_ENABLE_XFA |
| 123 options.m_pOCContext = |
| 124 new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View); |
| 125 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) |
| 126 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); |
| 140 #endif // PDF_ENABLE_XFA | 127 #endif // PDF_ENABLE_XFA |
| 141 | 128 |
| 142 pDevice->RestoreState(false); | 129 pDevice->RestoreState(false); |
| 143 delete options.m_pOCContext; | 130 delete options.m_pOCContext; |
| 144 #ifdef PDF_ENABLE_XFA | |
| 145 options.m_pOCContext = nullptr; | 131 options.m_pOCContext = nullptr; |
| 146 #endif // PDF_ENABLE_XFA | |
| 147 } | 132 } |
| 148 | 133 |
| 149 } // namespace | 134 } // namespace |
| 150 | 135 |
| 151 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, | 136 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
| 152 FPDF_PAGE page, | 137 FPDF_PAGE page, |
| 153 double page_x, | 138 double page_x, |
| 154 double page_y) { | 139 double page_y) { |
| 155 if (!hHandle) | 140 if (!hHandle) |
| 156 return -1; | 141 return -1; |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); | 712 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); |
| 728 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); | 713 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); |
| 729 } | 714 } |
| 730 } else { | 715 } else { |
| 731 if (aa.ActionExist(CPDF_AAction::ClosePage)) { | 716 if (aa.ActionExist(CPDF_AAction::ClosePage)) { |
| 732 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); | 717 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
| 733 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); | 718 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); |
| 734 } | 719 } |
| 735 } | 720 } |
| 736 } | 721 } |
| OLD | NEW |