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