John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Lei Zhang | b4e7f30 | 2015-11-06 15:52:32 -0800 | [diff] [blame] | 7 | #include "public/fpdf_formfill.h" |
| 8 | |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 9 | #include <memory> |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 10 | #include <vector> |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 11 | |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 12 | #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
Dan Sinclair | aa403d3 | 2016-03-15 14:57:22 -0400 | [diff] [blame] | 13 | #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 14 | #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" |
dsinclair | cac704d | 2016-07-28 12:59:09 -0700 | [diff] [blame] | 15 | #include "core/fpdfdoc/include/cpdf_formcontrol.h" |
| 16 | #include "core/fpdfdoc/include/cpdf_formfield.h" |
| 17 | #include "core/fpdfdoc/include/cpdf_interform.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 18 | #include "core/fpdfdoc/include/cpdf_occontext.h" |
npm | 9ada2d8 | 2016-08-10 07:51:38 -0700 | [diff] [blame] | 19 | #include "core/fxge/include/cfx_fxgedevice.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 20 | #include "fpdfsdk/include/cpdfsdk_document.h" |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 21 | #include "fpdfsdk/include/cpdfsdk_environment.h" |
jaepark | 611adb8 | 2016-08-17 11:34:36 -0700 | [diff] [blame] | 22 | #include "fpdfsdk/include/cpdfsdk_interform.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 23 | #include "fpdfsdk/include/cpdfsdk_pageview.h" |
| 24 | #include "fpdfsdk/include/fsdk_actionhandler.h" |
Lei Zhang | bde53d2 | 2015-11-12 22:21:30 -0800 | [diff] [blame] | 25 | #include "fpdfsdk/include/fsdk_define.h" |
Lei Zhang | b4e7f30 | 2015-11-06 15:52:32 -0800 | [diff] [blame] | 26 | #include "public/fpdfview.h" |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 27 | #include "third_party/base/stl_util.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 28 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 29 | #ifdef PDF_ENABLE_XFA |
dsinclair | 89bdd08 | 2016-04-06 10:47:54 -0700 | [diff] [blame] | 30 | #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" |
| 31 | #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
| 32 | #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" |
dsinclair | 7222ea6 | 2016-04-06 14:33:07 -0700 | [diff] [blame] | 33 | #include "xfa/fxfa/include/xfa_ffdocview.h" |
| 34 | #include "xfa/fxfa/include/xfa_ffpageview.h" |
| 35 | #include "xfa/fxfa/include/xfa_ffwidget.h" |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 36 | #endif // PDF_ENABLE_XFA |
| 37 | |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 38 | namespace { |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 39 | |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 40 | CPDFSDK_Environment* HandleToCPDFSDKEnvironment(FPDF_FORMHANDLE handle) { |
| 41 | return static_cast<CPDFSDK_Environment*>(handle); |
| 42 | } |
| 43 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 44 | CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { |
Tom Sepez | fe351db | 2016-01-29 16:26:27 -0800 | [diff] [blame] | 45 | CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 46 | return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 47 | } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 48 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 49 | CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, |
| 50 | FPDF_PAGE page) { |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 51 | UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); |
| 52 | if (!pPage) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 53 | return nullptr; |
Tom Sepez | 0b13398 | 2015-07-28 11:23:22 -0700 | [diff] [blame] | 54 | |
Tom Sepez | fe351db | 2016-01-29 16:26:27 -0800 | [diff] [blame] | 55 | CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
dsinclair | 461eeaf | 2016-07-27 07:40:05 -0700 | [diff] [blame] | 56 | return pSDKDoc ? pSDKDoc->GetPageView(pPage, true) : nullptr; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 57 | } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 58 | |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 59 | #ifdef PDF_ENABLE_XFA |
| 60 | std::vector<CFX_ByteString>* FromFPDFStringHandle(FPDF_STRINGHANDLE handle) { |
| 61 | return reinterpret_cast<std::vector<CFX_ByteString>*>(handle); |
| 62 | } |
| 63 | |
| 64 | FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) { |
| 65 | return reinterpret_cast<FPDF_STRINGHANDLE>(strings); |
| 66 | } |
| 67 | #endif // PDF_ENABLE_XFA |
| 68 | |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 69 | void FFLCommon(FPDF_FORMHANDLE hHandle, |
| 70 | FPDF_BITMAP bitmap, |
| 71 | FPDF_RECORDER recorder, |
| 72 | FPDF_PAGE page, |
| 73 | int start_x, |
| 74 | int start_y, |
| 75 | int size_x, |
| 76 | int size_y, |
| 77 | int rotate, |
| 78 | int flags) { |
| 79 | if (!hHandle) |
| 80 | return; |
| 81 | |
| 82 | UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); |
| 83 | if (!pPage) |
| 84 | return; |
| 85 | |
jaepark | 738766e | 2016-09-02 18:51:44 -0700 | [diff] [blame] | 86 | #ifdef PDF_ENABLE_XFA |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 87 | CPDFXFA_Document* pDocument = pPage->GetDocument(); |
| 88 | if (!pDocument) |
| 89 | return; |
| 90 | CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); |
| 91 | if (!pPDFDoc) |
| 92 | return; |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 93 | CPDFSDK_Environment* pEnv = HandleToCPDFSDKEnvironment(hHandle); |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 94 | CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); |
| 95 | if (!pFXDoc) |
| 96 | return; |
| 97 | #endif // PDF_ENABLE_XFA |
| 98 | |
| 99 | CFX_Matrix matrix; |
| 100 | pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); |
| 101 | |
| 102 | FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y); |
| 103 | |
| 104 | std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice); |
| 105 | #ifdef _SKIA_SUPPORT_ |
| 106 | pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder)); |
| 107 | #endif |
| 108 | pDevice->Attach(CFXBitmapFromFPDFBitmap(bitmap), false, nullptr, false); |
| 109 | pDevice->SaveState(); |
| 110 | pDevice->SetClip_Rect(clip); |
| 111 | |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 112 | CPDF_RenderOptions options; |
| 113 | if (flags & FPDF_LCD_TEXT) |
| 114 | options.m_Flags |= RENDER_CLEARTYPE; |
| 115 | else |
| 116 | options.m_Flags &= ~RENDER_CLEARTYPE; |
| 117 | |
| 118 | // Grayscale output |
| 119 | if (flags & FPDF_GRAYSCALE) { |
| 120 | options.m_ColorMode = RENDER_COLOR_GRAY; |
| 121 | options.m_ForeColor = 0; |
| 122 | options.m_BackColor = 0xffffff; |
| 123 | } |
| 124 | options.m_AddFlags = flags >> 8; |
jaepark | 75f84a5 | 2016-09-09 15:39:09 -0700 | [diff] [blame] | 125 | options.m_bDrawAnnots = flags & FPDF_ANNOT; |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 126 | |
jaepark | 738766e | 2016-09-02 18:51:44 -0700 | [diff] [blame] | 127 | #ifdef PDF_ENABLE_XFA |
| 128 | options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View); |
dsinclair | 461eeaf | 2016-07-27 07:40:05 -0700 | [diff] [blame] | 129 | if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage, true)) |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 130 | pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); |
jaepark | 738766e | 2016-09-02 18:51:44 -0700 | [diff] [blame] | 131 | #else // PDF_ENABLE_XFA |
| 132 | options.m_pOCContext = |
| 133 | new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View); |
| 134 | if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) |
| 135 | pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 136 | #endif // PDF_ENABLE_XFA |
| 137 | |
| 138 | pDevice->RestoreState(false); |
| 139 | delete options.m_pOCContext; |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 140 | options.m_pOCContext = nullptr; |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 143 | } // namespace |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 144 | |
Lei Zhang | bdf72c3 | 2015-08-14 19:24:08 -0700 | [diff] [blame] | 145 | DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
| 146 | FPDF_PAGE page, |
| 147 | double page_x, |
| 148 | double page_y) { |
Tom Sepez | db0be96 | 2015-10-16 14:00:21 -0700 | [diff] [blame] | 149 | if (!hHandle) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 150 | return -1; |
Tom Sepez | db0be96 | 2015-10-16 14:00:21 -0700 | [diff] [blame] | 151 | CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 152 | if (pPage) { |
thestig | db1a24e | 2016-05-23 16:55:09 -0700 | [diff] [blame] | 153 | CPDF_InterForm interform(pPage->m_pDocument); |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 154 | CPDF_FormControl* pFormCtrl = |
| 155 | interform.GetControlAtPoint(pPage, static_cast<FX_FLOAT>(page_x), |
| 156 | static_cast<FX_FLOAT>(page_y), nullptr); |
Lei Zhang | bdf72c3 | 2015-08-14 19:24:08 -0700 | [diff] [blame] | 157 | if (!pFormCtrl) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 158 | return -1; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 159 | CPDF_FormField* pFormField = pFormCtrl->GetField(); |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 160 | return pFormField ? pFormField->GetFieldType() : -1; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 163 | #ifdef PDF_ENABLE_XFA |
| 164 | CPDFXFA_Page* pXFAPage = UnderlyingFromFPDFPage(page); |
| 165 | if (!pXFAPage) |
| 166 | return -1; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 167 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 168 | CXFA_FFPageView* pPageView = pXFAPage->GetXFAPageView(); |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 169 | if (!pPageView) |
| 170 | return -1; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 171 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 172 | CXFA_FFDocView* pDocView = pPageView->GetDocView(); |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 173 | if (!pDocView) |
| 174 | return -1; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 175 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 176 | CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 177 | if (!pWidgetHandler) |
| 178 | return -1; |
| 179 | |
tsepez | cc4d6d8 | 2016-05-16 13:21:03 -0700 | [diff] [blame] | 180 | std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( |
dsinclair | 935d8d5 | 2016-05-17 10:32:18 -0700 | [diff] [blame] | 181 | pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, |
| 182 | XFA_WidgetStatus_Viewable)); |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 183 | if (!pWidgetIterator) |
| 184 | return -1; |
| 185 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 186 | CXFA_FFWidget* pXFAAnnot = pWidgetIterator->MoveToNext(); |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 187 | while (pXFAAnnot) { |
| 188 | CFX_RectF rcBBox; |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 189 | pXFAAnnot->GetBBox(rcBBox, 0); |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 190 | CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
| 191 | rcBBox.top + rcBBox.height); |
| 192 | rcWidget.left -= 1.0f; |
| 193 | rcWidget.right += 1.0f; |
| 194 | rcWidget.bottom -= 1.0f; |
| 195 | rcWidget.top += 1.0f; |
| 196 | |
| 197 | if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x), |
| 198 | static_cast<FX_FLOAT>(page_y))) { |
| 199 | return FPDF_FORMFIELD_XFA; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 200 | } |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 201 | pXFAAnnot = pWidgetIterator->MoveToNext(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 202 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 203 | #endif // PDF_ENABLE_XFA |
Lei Zhang | 7f9fdde | 2016-02-22 20:47:13 -0800 | [diff] [blame] | 204 | return -1; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Lei Zhang | bdf72c3 | 2015-08-14 19:24:08 -0700 | [diff] [blame] | 207 | DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
| 208 | FPDF_PAGE page, |
| 209 | double page_x, |
| 210 | double page_y) { |
| 211 | return FPDFPage_HasFormFieldAtPoint(hHandle, page, page_x, page_y); |
| 212 | } |
| 213 | |
| 214 | DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, |
| 215 | FPDF_PAGE page, |
| 216 | double page_x, |
| 217 | double page_y) { |
Tom Sepez | db0be96 | 2015-10-16 14:00:21 -0700 | [diff] [blame] | 218 | if (!hHandle) |
Lei Zhang | bdf72c3 | 2015-08-14 19:24:08 -0700 | [diff] [blame] | 219 | return -1; |
Tom Sepez | db0be96 | 2015-10-16 14:00:21 -0700 | [diff] [blame] | 220 | CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 221 | if (!pPage) |
| 222 | return -1; |
thestig | db1a24e | 2016-05-23 16:55:09 -0700 | [diff] [blame] | 223 | CPDF_InterForm interform(pPage->m_pDocument); |
Lei Zhang | bdf72c3 | 2015-08-14 19:24:08 -0700 | [diff] [blame] | 224 | int z_order = -1; |
| 225 | (void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, |
| 226 | &z_order); |
| 227 | return z_order; |
| 228 | } |
| 229 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 230 | DLLEXPORT FPDF_FORMHANDLE STDCALL |
| 231 | FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, |
| 232 | FPDF_FORMFILLINFO* formInfo) { |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 233 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 234 | const int kRequiredVersion = 2; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 235 | #else // PDF_ENABLE_XFA |
| 236 | const int kRequiredVersion = 1; |
| 237 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 238 | if (!formInfo || formInfo->version != kRequiredVersion) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 239 | return nullptr; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 240 | |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 241 | UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document); |
| 242 | if (!pDocument) |
| 243 | return nullptr; |
| 244 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 245 | #ifdef PDF_ENABLE_XFA |
dsinclair | a939bfe | 2016-09-22 13:18:45 -0700 | [diff] [blame] | 246 | // If the CPDFXFA_Document has a SDKDocument already then we've done this |
| 247 | // and can just return the old Env. Otherwise, we'll end up setting a new |
| 248 | // SDKDocument into the XFADocument and, that could get weird. |
| 249 | if (pDocument->GetSDKDoc()) |
| 250 | return pDocument->GetSDKDoc()->GetEnv(); |
| 251 | #endif |
| 252 | |
| 253 | CPDFSDK_Environment* pEnv = new CPDFSDK_Environment(pDocument, formInfo); |
| 254 | |
| 255 | #ifdef PDF_ENABLE_XFA |
| 256 | // Ownership of the SDKDocument is passed to the CPDFXFA_Document. |
| 257 | pDocument->SetSDKDoc(WrapUnique(pEnv->GetSDKDocument())); |
| 258 | CPDFXFA_App::GetInstance()->AddFormFillEnv(pEnv); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 259 | #endif // PDF_ENABLE_XFA |
dsinclair | a939bfe | 2016-09-22 13:18:45 -0700 | [diff] [blame] | 260 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 261 | return pEnv; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 264 | DLLEXPORT void STDCALL |
| 265 | FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { |
| 266 | if (!hHandle) |
| 267 | return; |
dsinclair | a939bfe | 2016-09-22 13:18:45 -0700 | [diff] [blame] | 268 | |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 269 | CPDFSDK_Environment* pEnv = HandleToCPDFSDKEnvironment(hHandle); |
dsinclair | a939bfe | 2016-09-22 13:18:45 -0700 | [diff] [blame] | 270 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 271 | #ifdef PDF_ENABLE_XFA |
dsinclair | a939bfe | 2016-09-22 13:18:45 -0700 | [diff] [blame] | 272 | CPDFXFA_App::GetInstance()->RemoveFormFillEnv(pEnv); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 273 | #else // PDF_ENABLE_XFA |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 274 | if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) { |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 275 | pEnv->SetSDKDocument(nullptr); |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 276 | delete pSDKDoc; |
| 277 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 278 | #endif // PDF_ENABLE_XFA |
dsinclair | a939bfe | 2016-09-22 13:18:45 -0700 | [diff] [blame] | 279 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 280 | delete pEnv; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 283 | DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, |
| 284 | FPDF_PAGE page, |
| 285 | int modifier, |
| 286 | double page_x, |
| 287 | double page_y) { |
| 288 | CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 289 | if (!pPageView) |
| 290 | return FALSE; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 291 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 292 | CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 293 | return pPageView->OnMouseMove(pt, modifier); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 294 | } |
| 295 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 296 | DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, |
| 297 | FPDF_PAGE page, |
| 298 | int modifier, |
| 299 | double page_x, |
| 300 | double page_y) { |
| 301 | CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 302 | if (!pPageView) |
| 303 | return FALSE; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 304 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 305 | CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 306 | return pPageView->OnLButtonDown(pt, modifier); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 309 | DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, |
| 310 | FPDF_PAGE page, |
| 311 | int modifier, |
| 312 | double page_x, |
| 313 | double page_y) { |
| 314 | CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 315 | if (!pPageView) |
| 316 | return FALSE; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 317 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 318 | CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 319 | return pPageView->OnLButtonUp(pt, modifier); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 322 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 323 | DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, |
| 324 | FPDF_PAGE page, |
| 325 | int modifier, |
| 326 | double page_x, |
| 327 | double page_y) { |
| 328 | CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 329 | if (!pPageView) |
| 330 | return FALSE; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 331 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 332 | CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 333 | return pPageView->OnRButtonDown(pt, modifier); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 336 | DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, |
| 337 | FPDF_PAGE page, |
| 338 | int modifier, |
| 339 | double page_x, |
| 340 | double page_y) { |
| 341 | CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 342 | if (!pPageView) |
| 343 | return FALSE; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 344 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 345 | CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 346 | return pPageView->OnRButtonUp(pt, modifier); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 347 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 348 | #endif // PDF_ENABLE_XFA |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 349 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 350 | DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, |
| 351 | FPDF_PAGE page, |
| 352 | int nKeyCode, |
| 353 | int modifier) { |
| 354 | CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 355 | if (!pPageView) |
| 356 | return FALSE; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 357 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 358 | return pPageView->OnKeyDown(nKeyCode, modifier); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 361 | DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, |
| 362 | FPDF_PAGE page, |
| 363 | int nKeyCode, |
| 364 | int modifier) { |
| 365 | CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 366 | if (!pPageView) |
| 367 | return FALSE; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 368 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 369 | return pPageView->OnKeyUp(nKeyCode, modifier); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 370 | } |
| 371 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 372 | DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, |
| 373 | FPDF_PAGE page, |
| 374 | int nChar, |
| 375 | int modifier) { |
| 376 | CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 377 | if (!pPageView) |
| 378 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 379 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 380 | return pPageView->OnChar(nChar, modifier); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 383 | DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) { |
Tom Sepez | fe351db | 2016-01-29 16:26:27 -0800 | [diff] [blame] | 384 | CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 385 | if (!pSDKDoc) |
| 386 | return FALSE; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 387 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 388 | return pSDKDoc->KillFocusAnnot(0); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Cary Clark | 399be5b | 2016-03-14 16:51:29 -0400 | [diff] [blame] | 391 | DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, |
| 392 | FPDF_BITMAP bitmap, |
| 393 | FPDF_PAGE page, |
| 394 | int start_x, |
| 395 | int start_y, |
| 396 | int size_x, |
| 397 | int size_y, |
| 398 | int rotate, |
| 399 | int flags) { |
| 400 | FFLCommon(hHandle, bitmap, nullptr, page, start_x, start_y, size_x, size_y, |
| 401 | rotate, flags); |
| 402 | } |
| 403 | |
| 404 | #ifdef _SKIA_SUPPORT_ |
| 405 | DLLEXPORT void STDCALL FPDF_FFLRecord(FPDF_FORMHANDLE hHandle, |
| 406 | FPDF_RECORDER recorder, |
| 407 | FPDF_PAGE page, |
| 408 | int start_x, |
| 409 | int start_y, |
| 410 | int size_x, |
| 411 | int size_y, |
| 412 | int rotate, |
| 413 | int flags) { |
| 414 | FFLCommon(hHandle, nullptr, recorder, page, start_x, start_y, size_x, size_y, |
| 415 | rotate, flags); |
| 416 | } |
| 417 | #endif |
| 418 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 419 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 420 | DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, |
| 421 | FPDF_WIDGET hWidget) { |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 422 | if (!hWidget || !document) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 423 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 424 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 425 | CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 426 | if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && |
| 427 | pDocument->GetDocType() != XFA_DOCTYPE_Static) |
| 428 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 429 | |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 430 | static_cast<CXFA_FFWidget*>(hWidget)->Undo(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 431 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 432 | DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, |
| 433 | FPDF_WIDGET hWidget) { |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 434 | if (!hWidget || !document) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 435 | return; |
Tom Sepez | bdeeb8a | 2015-05-27 12:25:00 -0700 | [diff] [blame] | 436 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 437 | CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 438 | if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && |
| 439 | pDocument->GetDocType() != XFA_DOCTYPE_Static) |
| 440 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 441 | |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 442 | static_cast<CXFA_FFWidget*>(hWidget)->Redo(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 443 | } |
| 444 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 445 | DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, |
| 446 | FPDF_WIDGET hWidget) { |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 447 | if (!hWidget || !document) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 448 | return; |
Tom Sepez | bdeeb8a | 2015-05-27 12:25:00 -0700 | [diff] [blame] | 449 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 450 | CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 451 | if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && |
| 452 | pDocument->GetDocType() != XFA_DOCTYPE_Static) |
| 453 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 454 | |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 455 | static_cast<CXFA_FFWidget*>(hWidget)->SelectAll(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 456 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 457 | DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, |
| 458 | FPDF_WIDGET hWidget, |
| 459 | FPDF_WIDESTRING wsText, |
| 460 | FPDF_DWORD* size) { |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 461 | if (!hWidget || !document) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 462 | return; |
Tom Sepez | bdeeb8a | 2015-05-27 12:25:00 -0700 | [diff] [blame] | 463 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 464 | CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 465 | if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && |
| 466 | pDocument->GetDocType() != XFA_DOCTYPE_Static) |
| 467 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 468 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 469 | CFX_WideString wsCpText; |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 470 | static_cast<CXFA_FFWidget*>(hWidget)->Copy(wsCpText); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 471 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 472 | CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); |
weili | 47ca692 | 2016-03-31 15:08:27 -0700 | [diff] [blame] | 473 | uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 474 | if (!wsText) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 475 | *size = len; |
| 476 | return; |
| 477 | } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 478 | |
weili | 47ca692 | 2016-03-31 15:08:27 -0700 | [diff] [blame] | 479 | uint32_t real_size = len < *size ? len : *size; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 480 | if (real_size > 0) { |
| 481 | FXSYS_memcpy((void*)wsText, |
| 482 | bsCpText.GetBuffer(real_size * sizeof(unsigned short)), |
| 483 | real_size * sizeof(unsigned short)); |
| 484 | bsCpText.ReleaseBuffer(real_size * sizeof(unsigned short)); |
| 485 | } |
| 486 | *size = real_size; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 487 | } |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 488 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 489 | DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, |
| 490 | FPDF_WIDGET hWidget, |
| 491 | FPDF_WIDESTRING wsText, |
| 492 | FPDF_DWORD* size) { |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 493 | if (!hWidget || !document) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 494 | return; |
thestig | befa450 | 2016-05-26 20:15:19 -0700 | [diff] [blame] | 495 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 496 | CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 497 | if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && |
| 498 | pDocument->GetDocType() != XFA_DOCTYPE_Static) |
| 499 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 500 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 501 | CFX_WideString wsCpText; |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 502 | static_cast<CXFA_FFWidget*>(hWidget)->Cut(wsCpText); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 503 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 504 | CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); |
weili | 47ca692 | 2016-03-31 15:08:27 -0700 | [diff] [blame] | 505 | uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 506 | if (!wsText) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 507 | *size = len; |
| 508 | return; |
| 509 | } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 510 | |
weili | 47ca692 | 2016-03-31 15:08:27 -0700 | [diff] [blame] | 511 | uint32_t real_size = len < *size ? len : *size; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 512 | if (real_size > 0) { |
| 513 | FXSYS_memcpy((void*)wsText, |
| 514 | bsCpText.GetBuffer(real_size * sizeof(unsigned short)), |
| 515 | real_size * sizeof(unsigned short)); |
| 516 | bsCpText.ReleaseBuffer(real_size * sizeof(unsigned short)); |
| 517 | } |
| 518 | *size = real_size; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 519 | } |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 520 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 521 | DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, |
| 522 | FPDF_WIDGET hWidget, |
| 523 | FPDF_WIDESTRING wsText, |
| 524 | FPDF_DWORD size) { |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 525 | if (!hWidget || !document) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 526 | return; |
Tom Sepez | bdeeb8a | 2015-05-27 12:25:00 -0700 | [diff] [blame] | 527 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 528 | CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 529 | if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && |
| 530 | pDocument->GetDocType() != XFA_DOCTYPE_Static) |
| 531 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 532 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 533 | CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size); |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 534 | static_cast<CXFA_FFWidget*>(hWidget)->Paste(wstr); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 535 | } |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 536 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 537 | DLLEXPORT void STDCALL |
| 538 | FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, |
| 539 | FPDF_WIDGET hWidget, |
| 540 | float x, |
| 541 | float y, |
| 542 | FPDF_BYTESTRING bsText) { |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 543 | if (!hWidget || !document) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 544 | return; |
Tom Sepez | bdeeb8a | 2015-05-27 12:25:00 -0700 | [diff] [blame] | 545 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 546 | CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 547 | if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && |
| 548 | pDocument->GetDocType() != XFA_DOCTYPE_Static) |
| 549 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 550 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 551 | CFX_PointF ptPopup; |
| 552 | ptPopup.x = x; |
| 553 | ptPopup.y = y; |
| 554 | CFX_ByteStringC bs(bsText); |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 555 | static_cast<CXFA_FFWidget*>(hWidget)->ReplaceSpellCheckWord(ptPopup, bs); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 556 | } |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 557 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 558 | DLLEXPORT void STDCALL |
| 559 | FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, |
| 560 | FPDF_WIDGET hWidget, |
| 561 | float x, |
| 562 | float y, |
| 563 | FPDF_STRINGHANDLE* stringHandle) { |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 564 | if (!hWidget || !document) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 565 | return; |
Tom Sepez | bdeeb8a | 2015-05-27 12:25:00 -0700 | [diff] [blame] | 566 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 567 | CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 568 | if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && |
| 569 | pDocument->GetDocType() != XFA_DOCTYPE_Static) |
| 570 | return; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 571 | |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 572 | std::vector<CFX_ByteString>* sSuggestWords = new std::vector<CFX_ByteString>; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 573 | CFX_PointF ptPopup; |
| 574 | ptPopup.x = x; |
| 575 | ptPopup.y = y; |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 576 | static_cast<CXFA_FFWidget*>(hWidget) |
| 577 | ->GetSuggestWords(ptPopup, *sSuggestWords); |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 578 | *stringHandle = ToFPDFStringHandle(sSuggestWords); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 579 | } |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 580 | |
| 581 | DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE sHandle) { |
| 582 | std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle); |
| 583 | return sSuggestWords ? pdfium::CollectionSize<int>(*sSuggestWords) : -1; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 584 | } |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 585 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 586 | DLLEXPORT FPDF_BOOL STDCALL |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 587 | FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 588 | int index, |
| 589 | FPDF_BYTESTRING bsText, |
| 590 | FPDF_DWORD* size) { |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 591 | if (!sHandle || !size) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 592 | return FALSE; |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 593 | |
| 594 | int count = FPDF_StringHandleCounts(sHandle); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 595 | if (index < 0 || index >= count) |
| 596 | return FALSE; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 597 | |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 598 | std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle); |
weili | 47ca692 | 2016-03-31 15:08:27 -0700 | [diff] [blame] | 599 | uint32_t len = (*sSuggestWords)[index].GetLength(); |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 600 | if (!bsText) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 601 | *size = len; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 602 | return TRUE; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 603 | } |
| 604 | |
weili | 47ca692 | 2016-03-31 15:08:27 -0700 | [diff] [blame] | 605 | uint32_t real_size = len < *size ? len : *size; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 606 | if (real_size > 0) |
tsepez | b4c9f3f | 2016-04-13 15:41:21 -0700 | [diff] [blame] | 607 | FXSYS_memcpy((void*)bsText, (*sSuggestWords)[index].c_str(), real_size); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 608 | *size = real_size; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 609 | return TRUE; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 610 | } |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 611 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 612 | DLLEXPORT void STDCALL |
| 613 | FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle) { |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 614 | delete FromFPDFStringHandle(stringHandle); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 615 | } |
| 616 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 617 | DLLEXPORT FPDF_BOOL STDCALL |
| 618 | FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle, |
| 619 | FPDF_BYTESTRING bsText, |
| 620 | FPDF_DWORD size) { |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 621 | if (!stringHandle || !bsText || size == 0) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 622 | return FALSE; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 623 | |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 624 | FromFPDFStringHandle(stringHandle)->push_back(CFX_ByteString(bsText, size)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 625 | return TRUE; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 626 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 627 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 628 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 629 | DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, |
| 630 | int fieldType, |
| 631 | unsigned long color) { |
| 632 | if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
| 633 | pInterForm->SetHighlightColor(color, fieldType); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 634 | } |
| 635 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 636 | DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, |
| 637 | unsigned char alpha) { |
| 638 | if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
| 639 | pInterForm->SetHighlightAlpha(alpha); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 642 | DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) { |
| 643 | if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
| 644 | pInterForm->RemoveAllHighLight(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 645 | } |
| 646 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 647 | DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, |
| 648 | FPDF_FORMHANDLE hHandle) { |
| 649 | if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) |
| 650 | pPageView->SetValid(TRUE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 651 | } |
| 652 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 653 | DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, |
| 654 | FPDF_FORMHANDLE hHandle) { |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 655 | if (!hHandle) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 656 | return; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 657 | |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 658 | CPDFSDK_Document* pSDKDoc = |
| 659 | HandleToCPDFSDKEnvironment(hHandle)->GetSDKDocument(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 660 | if (!pSDKDoc) |
| 661 | return; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 662 | |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 663 | UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); |
| 664 | if (!pPage) |
| 665 | return; |
| 666 | |
dsinclair | 461eeaf | 2016-07-27 07:40:05 -0700 | [diff] [blame] | 667 | CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 668 | if (pPageView) { |
| 669 | pPageView->SetValid(FALSE); |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 670 | // RemovePageView() takes care of the delete for us. |
| 671 | pSDKDoc->RemovePageView(pPage); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 672 | } |
| 673 | } |
| 674 | |
| 675 | DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) { |
Tom Sepez | fe351db | 2016-01-29 16:26:27 -0800 | [diff] [blame] | 676 | CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 677 | if (pSDKDoc && HandleToCPDFSDKEnvironment(hHandle)->IsJSInitiated()) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 678 | pSDKDoc->ProcJavascriptFun(); |
| 679 | } |
| 680 | |
| 681 | DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) { |
Tom Sepez | fe351db | 2016-01-29 16:26:27 -0800 | [diff] [blame] | 682 | CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 683 | if (pSDKDoc && HandleToCPDFSDKEnvironment(hHandle)->IsJSInitiated()) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 684 | pSDKDoc->ProcOpenAction(); |
| 685 | } |
| 686 | |
| 687 | DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, |
| 688 | int aaType) { |
Tom Sepez | fe351db | 2016-01-29 16:26:27 -0800 | [diff] [blame] | 689 | CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 690 | if (!pSDKDoc) |
| 691 | return; |
| 692 | |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 693 | CPDF_Document* pDoc = pSDKDoc->GetPDFDocument(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 694 | CPDF_Dictionary* pDic = pDoc->GetRoot(); |
| 695 | if (!pDic) |
| 696 | return; |
Tom Sepez | 468e589 | 2015-10-13 15:49:36 -0700 | [diff] [blame] | 697 | |
dsinclair | 38fd844 | 2016-09-15 10:15:32 -0700 | [diff] [blame] | 698 | CPDF_AAction aa(pDic->GetDictFor("AA")); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 699 | if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) { |
| 700 | CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType); |
| 701 | CPDFSDK_ActionHandler* pActionHandler = |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 702 | HandleToCPDFSDKEnvironment(hHandle)->GetActionHander(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 703 | pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType, |
| 704 | pSDKDoc); |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, |
| 709 | FPDF_FORMHANDLE hHandle, |
| 710 | int aaType) { |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 711 | if (!hHandle) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 712 | return; |
tonikitoo | 401d4f2 | 2016-08-10 11:37:45 -0700 | [diff] [blame] | 713 | |
| 714 | CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
| 715 | if (!pSDKDoc) |
| 716 | return; |
| 717 | |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 718 | UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); |
| 719 | CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page); |
Tom Sepez | de4791d | 2015-10-30 12:13:10 -0700 | [diff] [blame] | 720 | if (!pPDFPage) |
| 721 | return; |
tonikitoo | 401d4f2 | 2016-08-10 11:37:45 -0700 | [diff] [blame] | 722 | |
| 723 | if (!pSDKDoc->GetPageView(pPage, false)) |
| 724 | return; |
| 725 | |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 726 | CPDFSDK_Environment* pEnv = pSDKDoc->GetEnv(); |
tonikitoo | 401d4f2 | 2016-08-10 11:37:45 -0700 | [diff] [blame] | 727 | CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
| 728 | CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict; |
dsinclair | 38fd844 | 2016-09-15 10:15:32 -0700 | [diff] [blame] | 729 | CPDF_AAction aa(pPageDict->GetDictFor("AA")); |
tonikitoo | 401d4f2 | 2016-08-10 11:37:45 -0700 | [diff] [blame] | 730 | if (FPDFPAGE_AACTION_OPEN == aaType) { |
| 731 | if (aa.ActionExist(CPDF_AAction::OpenPage)) { |
| 732 | CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); |
| 733 | pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); |
| 734 | } |
| 735 | } else { |
| 736 | if (aa.ActionExist(CPDF_AAction::ClosePage)) { |
| 737 | CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
| 738 | pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 739 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 740 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 741 | } |