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