| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../public/fpdf_formfill.h" | 7 #include "../../public/fpdf_formfill.h" |
| 8 #include "../../public/fpdfview.h" | 8 #include "../../public/fpdfview.h" |
| 9 #include "../include/fsdk_define.h" | 9 #include "../include/fsdk_define.h" |
| 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 11 #include "../include/fsdk_mgr.h" | 11 #include "../include/fsdk_mgr.h" |
| 12 #include "../include/fpdfxfa/fpdfxfa_page.h" | 12 #include "../include/fpdfxfa/fpdfxfa_page.h" |
| 13 #include "../include/fpdfxfa/fpdfxfa_app.h" | 13 #include "../include/fpdfxfa/fpdfxfa_app.h" |
| 14 | 14 |
| 15 | 15 |
| 16 #include "../include/javascript/IJavaScript.h" | 16 #include "../include/javascript/IJavaScript.h" |
| 17 | 17 |
| 18 | 18 namespace { |
| 19 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_
PAGE page,double page_x, double page_y) | 19 |
| 20 { | 20 CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle) |
| 21 » if(!page || !hHandle) | 21 { |
| 22 » » return -1; | 22 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; |
| 23 » CPDF_Page * pPage = ((CPDFXFA_Page*) page)->GetPDFPage(); | 23 return pEnv ? pEnv->GetSDKDocument() : nullptr; |
| 24 » if (pPage) | 24 } |
| 25 » { | 25 |
| 26 » » CPDF_InterForm * pInterForm = NULL; | 26 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) |
| 27 » » pInterForm = new CPDF_InterForm(pPage->m_pDocument,FALSE); | 27 { |
| 28 » » if (!pInterForm) | 28 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
| 29 » » » return -1; | 29 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; |
| 30 » » CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(pPag
e, (FX_FLOAT)page_x, (FX_FLOAT)page_y); | 30 } |
| 31 » » if(!pFormCtrl) | 31 |
| 32 » » { | 32 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page) |
| 33 » » » delete pInterForm; | 33 { |
| 34 » » » return -1; | 34 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
| 35 » » } | 35 return pSDKDoc ? pSDKDoc->GetPageView((CPDFXFA_Page*)page, TRUE) : nullptr; |
| 36 » » CPDF_FormField* pFormField = pFormCtrl->GetField(); | 36 } |
| 37 » » if(!pFormField) | 37 |
| 38 » » { | 38 } // namespace |
| 39 » » » delete pInterForm; | 39 |
| 40 » » » return -1; | 40 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint( |
| 41 » » } | 41 FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y) |
| 42 | 42 { |
| 43 » » int nType = pFormField->GetFieldType(); | 43 if(!page || !hHandle) |
| 44 » » delete pInterForm; | 44 return -1; |
| 45 » » return nType; | 45 CPDF_Page * pPage = ((CPDFXFA_Page*) page)->GetPDFPage(); |
| 46 » } | 46 if (pPage) |
| 47 | 47 { |
| 48 » IXFA_PageView* pPageView = ((CPDFXFA_Page*)page)->GetXFAPageView(); | 48 CPDF_InterForm * pInterForm = NULL; |
| 49 » if (pPageView) | 49 pInterForm = new CPDF_InterForm(pPage->m_pDocument,FALSE); |
| 50 » { | 50 if (!pInterForm) |
| 51 » » IXFA_WidgetHandler* pWidgetHandler = NULL; | 51 return -1; |
| 52 » » IXFA_DocView* pDocView = pPageView->GetDocView(); | 52 CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(pPage, (FX_F
LOAT)page_x, (FX_FLOAT)page_y); |
| 53 » » if (!pDocView) | 53 if(!pFormCtrl) |
| 54 » » » return -1; | 54 { |
| 55 | 55 delete pInterForm; |
| 56 » » pWidgetHandler = pDocView->GetWidgetHandler(); | 56 return -1; |
| 57 » » if (!pWidgetHandler) | 57 } |
| 58 » » » return -1; | 58 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
| 59 | 59 if(!pFormField) |
| 60 » » IXFA_Widget* pXFAAnnot = NULL; | 60 { |
| 61 » » IXFA_WidgetIterator* pWidgetIterator = pPageView->CreateWidgetIt
erator(XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Viewable|XFA_WIDGETFILTER_AllType)
; | 61 delete pInterForm; |
| 62 » » if (!pWidgetIterator) | 62 return -1; |
| 63 » » » return -1; | 63 } |
| 64 » » pXFAAnnot = pWidgetIterator->MoveToNext(); | 64 |
| 65 » » while (pXFAAnnot) { | 65 int nType = pFormField->GetFieldType(); |
| 66 » » » CFX_RectF rcBBox; | 66 delete pInterForm; |
| 67 » » » pWidgetHandler->GetBBox (pXFAAnnot, rcBBox, 0); | 67 return nType; |
| 68 » » » CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.l
eft + rcBBox.width, rcBBox.top+rcBBox.height); | 68 } |
| 69 » » » rcWidget.left -= 1.0f; | 69 |
| 70 » » » rcWidget.right += 1.0f; | 70 IXFA_PageView* pPageView = ((CPDFXFA_Page*)page)->GetXFAPageView(); |
| 71 » » » rcWidget.bottom -= 1.0f; | 71 if (pPageView) |
| 72 » » » rcWidget.top += 1.0f; | 72 { |
| 73 | 73 IXFA_WidgetHandler* pWidgetHandler = NULL; |
| 74 » » » if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x), | 74 IXFA_DocView* pDocView = pPageView->GetDocView(); |
| 75 » » » » static_cast<FX_FLOAT>(page_y))) { | 75 if (!pDocView) |
| 76 » » » » pWidgetIterator->Release(); | 76 return -1; |
| 77 » » » » return FPDF_FORMFIELD_XFA; | 77 |
| 78 » » » } | 78 pWidgetHandler = pDocView->GetWidgetHandler(); |
| 79 » » » pXFAAnnot = pWidgetIterator->MoveToNext(); | 79 if (!pWidgetHandler) |
| 80 » » } | 80 return -1; |
| 81 | 81 |
| 82 » » pWidgetIterator->Release(); | 82 IXFA_Widget* pXFAAnnot = NULL; |
| 83 » } | 83 IXFA_WidgetIterator* pWidgetIterator = pPageView->CreateWidgetIterator(X
FA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Viewable|XFA_WIDGETFILTER_AllType); |
| 84 | 84 if (!pWidgetIterator) |
| 85 » return -1; | 85 return -1; |
| 86 pXFAAnnot = pWidgetIterator->MoveToNext(); |
| 87 while (pXFAAnnot) { |
| 88 CFX_RectF rcBBox; |
| 89 pWidgetHandler->GetBBox (pXFAAnnot, rcBBox, 0); |
| 90 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox
.width, rcBBox.top+rcBBox.height); |
| 91 rcWidget.left -= 1.0f; |
| 92 rcWidget.right += 1.0f; |
| 93 rcWidget.bottom -= 1.0f; |
| 94 rcWidget.top += 1.0f; |
| 95 |
| 96 if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x), |
| 97 static_cast<FX_FLOAT>(page_y))) { |
| 98 pWidgetIterator->Release(); |
| 99 return FPDF_FORMFIELD_XFA; |
| 100 } |
| 101 pXFAAnnot = pWidgetIterator->MoveToNext(); |
| 102 } |
| 103 |
| 104 pWidgetIterator->Release(); |
| 105 } |
| 106 |
| 107 return -1; |
| 86 } | 108 } |
| 87 | 109 |
| 88 DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT
document, FPDF_FORMFILLINFO* formInfo) | 110 DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT
document, FPDF_FORMFILLINFO* formInfo) |
| 89 { | 111 { |
| 90 » if(!document || !formInfo || formInfo->version!=2) | 112 if (!document || !formInfo || formInfo->version != 2) |
| 91 » » return NULL; | 113 return nullptr; |
| 92 » CPDFXFA_Document * pDocument = (CPDFXFA_Document*) document; | 114 |
| 93 » CPDFDoc_Environment * pEnv = NULL; | 115 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 94 » pEnv = new CPDFDoc_Environment(pDocument); | 116 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); |
| 95 » if (!pEnv) | 117 pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); |
| 96 » » return NULL; | 118 |
| 97 » pEnv->RegAppHandle(formInfo); | 119 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); |
| 98 | 120 pApp->AddFormFillEnv(pEnv); |
| 99 » CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); | 121 |
| 100 » pApp->AddFormFillEnv(pEnv); | 122 return pEnv; |
| 101 | |
| 102 » if(pEnv->GetPDFXFADocument()) | |
| 103 » { | |
| 104 » » //CPDFSDK_Document* pSDKDoc = new CPDFSDK_Document(pEnv->GetPDFX
FADocument(), pEnv); | |
| 105 » » CPDFSDK_Document* pSDKDoc = pDocument->GetSDKDocument(pEnv); | |
| 106 » » if(pSDKDoc) { | |
| 107 » » » pEnv->SetCurrentDoc(pSDKDoc); | |
| 108 » » } | |
| 109 » } | |
| 110 » return pEnv; | |
| 111 } | 123 } |
| 112 | 124 |
| 113 DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) | 125 DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) |
| 114 { | 126 { |
| 115 » if (!hHandle) | 127 if (!hHandle) |
| 116 » » return; | 128 return; |
| 117 » CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); | 129 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); |
| 118 » pApp->RemoveFormFillEnv((CPDFDoc_Environment*)hHandle); | 130 pApp->RemoveFormFillEnv((CPDFDoc_Environment*)hHandle); |
| 119 » delete (CPDFDoc_Environment*)hHandle; | 131 delete (CPDFDoc_Environment*)hHandle; |
| 120 » hHandle = NULL; | |
| 121 } | 132 } |
| 122 | 133 |
| 123 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) | 134 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) |
| 124 { | 135 { |
| 125 » if (!hHandle || !page) | 136 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 126 » » return FALSE; | 137 if (!pPageView) |
| 127 // » CPDF_Page * pPage = (CPDF_Page*) page; | 138 return FALSE; |
| 128 // » CPDF_Document * pDoc = pPage->m_pDocument; | 139 |
| 129 //» CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; | 140 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
| 130 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 141 return pPageView->OnMouseMove(pt, modifier); |
| 131 » if(!pFXDoc) | |
| 132 » » return FALSE; | |
| 133 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
| 134 » if(!pPageView) | |
| 135 » » return FALSE; | |
| 136 | |
| 137 // » double page_x = 0; | |
| 138 // » double page_y = 0; | |
| 139 //» pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
| 140 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
| 141 » return pPageView->OnMouseMove(pt, modifier); | |
| 142 } | 142 } |
| 143 | 143 |
| 144 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG
E page, int modifier, double page_x, double page_y) | 144 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG
E page, int modifier, double page_x, double page_y) |
| 145 { | 145 { |
| 146 » if (!hHandle || !page) | 146 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 147 » » return FALSE; | 147 if (!pPageView) |
| 148 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 148 return FALSE; |
| 149 » if(!pFXDoc) | 149 |
| 150 » » return FALSE; | 150 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
| 151 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | 151 return pPageView->OnLButtonDown(pt, modifier); |
| 152 » if(!pPageView) | |
| 153 » » return FALSE; | |
| 154 // » double page_x = 0; | |
| 155 // » double page_y = 0; | |
| 156 // » pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
| 157 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
| 158 » return pPageView->OnLButtonDown(pt, modifier); | |
| 159 } | 152 } |
| 160 | 153 |
| 161 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) | 154 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) |
| 162 { | 155 { |
| 163 » if (!hHandle || !page) | 156 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 164 » » return FALSE; | 157 if (!pPageView) |
| 165 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 158 return FALSE; |
| 166 » if(!pFXDoc) | 159 |
| 167 » » return FALSE; | 160 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
| 168 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | 161 return pPageView->OnLButtonUp(pt, modifier); |
| 169 » if(!pPageView) | |
| 170 » » return FALSE; | |
| 171 // » double page_x = 0; | |
| 172 // » double page_y = 0; | |
| 173 // » pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
| 174 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
| 175 » return pPageView->OnLButtonUp(pt, modifier); | |
| 176 } | 162 } |
| 177 | 163 |
| 178 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG
E page, int modifier, double page_x, double page_y) | 164 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG
E page, int modifier, double page_x, double page_y) |
| 179 { | 165 { |
| 180 » if (!hHandle || !page) | 166 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 181 » » return FALSE; | 167 if (!pPageView) |
| 182 | 168 return FALSE; |
| 183 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 169 |
| 184 » if(!pFXDoc) | 170 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
| 185 » » return FALSE; | 171 return pPageView->OnRButtonDown(pt, modifier); |
| 186 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
| 187 » if(!pPageView) | |
| 188 » » return FALSE; | |
| 189 | |
| 190 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
| 191 » return pPageView->OnRButtonDown(pt, modifier); | |
| 192 } | 172 } |
| 193 | 173 |
| 194 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) | 174 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) |
| 195 { | 175 { |
| 196 » if (!hHandle || !page) | 176 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 197 » » return FALSE; | 177 if (!pPageView) |
| 198 | 178 return FALSE; |
| 199 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 179 |
| 200 » if(!pFXDoc) | 180 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
| 201 » » return FALSE; | 181 return pPageView->OnRButtonUp(pt, modifier); |
| 202 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
| 203 » if(!pPageView) | |
| 204 » » return FALSE; | |
| 205 | |
| 206 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
| 207 » return pPageView->OnRButtonUp(pt, modifier); | |
| 208 } | 182 } |
| 209 | 183 |
| 210 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa
ge, int nKeyCode, int modifier) | 184 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa
ge, int nKeyCode, int modifier) |
| 211 { | 185 { |
| 212 » if (!hHandle || !page) | 186 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 213 » » return FALSE; | 187 if (!pPageView) |
| 214 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 188 return FALSE; |
| 215 » if(!pFXDoc) | 189 |
| 216 » » return FALSE; | 190 return pPageView->OnKeyDown(nKeyCode, modifier); |
| 217 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
| 218 » if(!pPageView) | |
| 219 » » return FALSE; | |
| 220 | |
| 221 | |
| 222 » return pPageView->OnKeyDown(nKeyCode, modifier); | |
| 223 } | 191 } |
| 224 | 192 |
| 225 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page
, int nKeyCode, int modifier) | 193 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page
, int nKeyCode, int modifier) |
| 226 { | 194 { |
| 227 » if (!hHandle || !page) | 195 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 228 » » return FALSE; | 196 if (!pPageView) |
| 229 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 197 return FALSE; |
| 230 » if(!pFXDoc) | 198 |
| 231 » » return FALSE; | 199 return pPageView->OnKeyUp(nKeyCode, modifier); |
| 232 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | 200 } |
| 233 » if(!pPageView) | |
| 234 » » return FALSE; | |
| 235 | |
| 236 | |
| 237 » return pPageView->OnKeyUp(nKeyCode, modifier); | |
| 238 } | |
| 239 | |
| 240 | 201 |
| 241 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page,
int nChar, int modifier) | 202 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page,
int nChar, int modifier) |
| 242 { | 203 { |
| 243 » if (!hHandle || !page) | 204 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
| 244 » » return FALSE; | 205 if (!pPageView) |
| 245 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 206 return FALSE; |
| 246 » if(!pFXDoc) | 207 |
| 247 » » return FALSE; | 208 return pPageView->OnChar(nChar, modifier); |
| 248 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
| 249 » if(!pPageView) | |
| 250 » » return FALSE; | |
| 251 » return pPageView->OnChar(nChar, modifier); | |
| 252 | |
| 253 } | 209 } |
| 254 | 210 |
| 255 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) | 211 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) |
| 256 { | 212 { |
| 257 » if(!hHandle) | 213 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
| 258 » » return FALSE; | 214 if (!pSDKDoc) |
| 259 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 215 return FALSE; |
| 260 » if(!pSDKDoc) | 216 |
| 261 » » return FALSE; | 217 return pSDKDoc->KillFocusAnnot(0); |
| 262 » //Kill the current focus. | 218 } |
| 263 » return pSDKDoc->KillFocusAnnot(0); | 219 |
| 264 } | 220 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
FPDF_PAGE page, |
| 265 | 221 int start_x, int start_y, int size_x, int si
ze_y, int rotate, int flags) |
| 266 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
FPDF_PAGE page, int start_x, int start_y, | 222 { |
| 267 » » » » » » » » » »
» » int size_x, int size_y, int rotate, int flags) | 223 if (!hHandle || !page) |
| 268 { | 224 return ; |
| 269 » if (!hHandle || !page) | 225 |
| 270 » » return ; | 226 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; |
| 271 | 227 CPDFXFA_Document* pDocument = pPage->GetDocument(); |
| 272 » CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | 228 if (!pDocument) |
| 273 » CPDFXFA_Document* pDocument = pPage->GetDocument(); | 229 return; |
| 274 » if (!pDocument) | 230 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); |
| 275 » » return; | 231 if (!pPDFDoc) |
| 276 » CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); | 232 return; |
| 277 » if (!pPDFDoc) | 233 |
| 278 » » return; | 234 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; |
| 279 | 235 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); |
| 280 » CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; | 236 if (!pFXDoc) |
| 281 » CPDFSDK_Document* pFXDoc = pEnv->GetCurrentDoc(); | 237 return; |
| 282 » if (!pFXDoc) | 238 |
| 283 » » return; | 239 CFX_AffineMatrix matrix; |
| 284 | 240 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); |
| 285 » CFX_AffineMatrix matrix; | 241 |
| 286 » pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate
); | 242 FX_RECT clip; |
| 287 | 243 clip.left = start_x; |
| 288 » FX_RECT clip; | 244 clip.right = start_x + size_x; |
| 289 » clip.left = start_x; | 245 clip.top = start_y; |
| 290 » clip.right = start_x + size_x; | 246 clip.bottom = start_y + size_y; |
| 291 » clip.top = start_y; | |
| 292 » clip.bottom = start_y + size_y; | |
| 293 | 247 |
| 294 #ifdef _SKIA_SUPPORT_ | 248 #ifdef _SKIA_SUPPORT_ |
| 295 » CFX_SkiaDevice* pDevice = FX_NEW CFX_SkiaDevice; | 249 nonstd::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice); |
| 296 #else | 250 #else |
| 297 » CFX_FxgeDevice* pDevice = NULL; | 251 nonstd::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice); |
| 298 » pDevice = FX_NEW CFX_FxgeDevice; | |
| 299 #endif | 252 #endif |
| 300 | 253 |
| 301 » if (!pDevice) | 254 if (!pDevice) |
| 302 » » return; | 255 return; |
| 303 » pDevice->Attach((CFX_DIBitmap*)bitmap); | 256 pDevice->Attach((CFX_DIBitmap*)bitmap); |
| 304 » pDevice->SaveState(); | 257 pDevice->SaveState(); |
| 305 » pDevice->SetClip_Rect(&clip); | 258 pDevice->SetClip_Rect(&clip); |
| 306 | 259 |
| 307 » CPDF_RenderOptions options; | 260 CPDF_RenderOptions options; |
| 308 » if (flags & FPDF_LCD_TEXT) | 261 if (flags & FPDF_LCD_TEXT) |
| 309 » » options.m_Flags |= RENDER_CLEARTYPE; | 262 options.m_Flags |= RENDER_CLEARTYPE; |
| 310 » else | 263 else |
| 311 » » options.m_Flags &= ~RENDER_CLEARTYPE; | 264 options.m_Flags &= ~RENDER_CLEARTYPE; |
| 312 | 265 |
| 313 » //Grayscale output | 266 //Grayscale output |
| 314 » if (flags & FPDF_GRAYSCALE) | 267 if (flags & FPDF_GRAYSCALE) |
| 315 » { | 268 { |
| 316 » » options.m_ColorMode = RENDER_COLOR_GRAY; | 269 options.m_ColorMode = RENDER_COLOR_GRAY; |
| 317 » » options.m_ForeColor = 0; | 270 options.m_ForeColor = 0; |
| 318 » » options.m_BackColor = 0xffffff; | 271 options.m_BackColor = 0xffffff; |
| 319 » } | 272 } |
| 320 » options.m_AddFlags = flags >> 8; | 273 options.m_AddFlags = flags >> 8; |
| 321 | 274 options.m_pOCContext = FX_NEW CPDF_OCContext(pPDFDoc); |
| 322 » options.m_pOCContext = FX_NEW CPDF_OCContext(pPDFDoc); | 275 |
| 323 | 276 if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page)) |
| 324 » if(CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page
)) | 277 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, &clip); |
| 325 » { | 278 |
| 326 » » pPageView->PageView_OnDraw(pDevice, &matrix, &options, &clip); | 279 pDevice->RestoreState(); |
| 327 » } | 280 |
| 328 » pDevice->RestoreState(); | 281 delete options.m_pOCContext; |
| 329 | 282 options.m_pOCContext = NULL; |
| 330 » if(options.m_pOCContext) | |
| 331 » { | |
| 332 » » delete options.m_pOCContext; | |
| 333 » » options.m_pOCContext = NULL; | |
| 334 » } | |
| 335 » if(pDevice) | |
| 336 » { | |
| 337 » » delete pDevice; | |
| 338 » » pDevice = NULL; | |
| 339 » } | |
| 340 | |
| 341 } | 283 } |
| 342 DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get) | 284 DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get) |
| 343 { | 285 { |
| 344 » if (NULL == hWidget || NULL == document) | 286 if (NULL == hWidget || NULL == document) |
| 345 » » return; | 287 return; |
| 346 | 288 |
| 347 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 289 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 348 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 290 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType(
) != XFA_DOCTYPE_Static) |
| 349 » » return; | 291 return; |
| 350 | 292 |
| 351 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 293 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->
GetMenuHandler(); |
| 352 » if (pXFAMenuHander == NULL) | 294 if (pXFAMenuHander == NULL) |
| 353 » » return; | 295 return; |
| 354 | 296 |
| 355 » pXFAMenuHander->Undo((IXFA_Widget*)hWidget); | 297 pXFAMenuHander->Undo((IXFA_Widget*)hWidget); |
| 356 | 298 |
| 357 } | 299 } |
| 358 DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get) | 300 DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get) |
| 359 { | 301 { |
| 360 » if (NULL == hWidget || NULL == document) | 302 if (NULL == hWidget || NULL == document) |
| 361 » » return; | 303 return; |
| 362 | 304 |
| 363 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 305 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 364 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 306 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType(
) != XFA_DOCTYPE_Static) |
| 365 » » return; | 307 return; |
| 366 | 308 |
| 367 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 309 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->
GetMenuHandler(); |
| 368 » if (pXFAMenuHander == NULL) | 310 if (pXFAMenuHander == NULL) |
| 369 » » return; | 311 return; |
| 370 | 312 |
| 371 » pXFAMenuHander->Redo((IXFA_Widget*)hWidget); | 313 pXFAMenuHander->Redo((IXFA_Widget*)hWidget); |
| 372 } | 314 } |
| 373 | 315 |
| 374 DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET
hWidget) | 316 DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET
hWidget) |
| 375 { | 317 { |
| 376 » if (NULL == hWidget || NULL == document) | 318 if (NULL == hWidget || NULL == document) |
| 377 » » return; | 319 return; |
| 378 | 320 |
| 379 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 321 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 380 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 322 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType(
) != XFA_DOCTYPE_Static) |
| 381 » » return; | 323 return; |
| 382 | 324 |
| 383 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 325 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->
GetMenuHandler(); |
| 384 » if (pXFAMenuHander == NULL) | 326 if (pXFAMenuHander == NULL) |
| 385 » » return; | 327 return; |
| 386 | 328 |
| 387 » pXFAMenuHander->SelectAll((IXFA_Widget*)hWidget); | 329 pXFAMenuHander->SelectAll((IXFA_Widget*)hWidget); |
| 388 } | 330 } |
| 389 DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get, FPDF_WIDESTRING wsText, FPDF_DWORD* size) | 331 DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get, FPDF_WIDESTRING wsText, FPDF_DWORD* size) |
| 390 { | 332 { |
| 391 » if (NULL == hWidget || NULL == document) | 333 if (NULL == hWidget || NULL == document) |
| 392 » » return; | 334 return; |
| 393 | 335 |
| 394 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 336 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 395 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 337 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType(
) != XFA_DOCTYPE_Static) |
| 396 » » return; | 338 return; |
| 397 | 339 |
| 398 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 340 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->
GetMenuHandler(); |
| 399 » if (pXFAMenuHander == NULL) | 341 if (pXFAMenuHander == NULL) |
| 400 » » return; | 342 return; |
| 401 | 343 |
| 402 » CFX_WideString wsCpText; | 344 CFX_WideString wsCpText; |
| 403 » pXFAMenuHander->Copy((IXFA_Widget*)hWidget, wsCpText); | 345 pXFAMenuHander->Copy((IXFA_Widget*)hWidget, wsCpText); |
| 404 | 346 |
| 405 » CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); | 347 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); |
| 406 » int len = bsCpText.GetLength()/sizeof(unsigned short); | 348 int len = bsCpText.GetLength()/sizeof(unsigned short); |
| 407 » if (wsText == NULL) { | 349 if (wsText == NULL) { |
| 408 » » *size = len; | 350 *size = len; |
| 409 » » return; | 351 return; |
| 410 » } | 352 } |
| 411 | 353 |
| 412 » int real_size = len < *size ? len : *size; | 354 int real_size = len < *size ? len : *size; |
| 413 » if (real_size > 0) | 355 if (real_size > 0) |
| 414 » { | 356 { |
| 415 » » FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(u
nsigned short)),real_size*sizeof(unsigned short)); | 357 FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(unsigned
short)),real_size*sizeof(unsigned short)); |
| 416 » » bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); | 358 bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); |
| 417 » } | 359 } |
| 418 » *size = real_size; | 360 *size = real_size; |
| 419 } | 361 } |
| 420 DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidg
et, FPDF_WIDESTRING wsText, FPDF_DWORD* size) | 362 DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidg
et, FPDF_WIDESTRING wsText, FPDF_DWORD* size) |
| 421 { | 363 { |
| 422 » if (NULL == hWidget || NULL == document) | 364 if (NULL == hWidget || NULL == document) |
| 423 » » return; | 365 return; |
| 424 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 366 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 425 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 367 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType(
) != XFA_DOCTYPE_Static) |
| 426 » » return; | 368 return; |
| 427 | 369 |
| 428 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 370 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->
GetMenuHandler(); |
| 429 » if (pXFAMenuHander == NULL) | 371 if (pXFAMenuHander == NULL) |
| 430 » » return; | 372 return; |
| 431 | 373 |
| 432 » CFX_WideString wsCpText; | 374 CFX_WideString wsCpText; |
| 433 » pXFAMenuHander->Cut((IXFA_Widget*)hWidget, wsCpText); | 375 pXFAMenuHander->Cut((IXFA_Widget*)hWidget, wsCpText); |
| 434 | 376 |
| 435 » CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); | 377 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); |
| 436 » int len = bsCpText.GetLength()/sizeof(unsigned short); | 378 int len = bsCpText.GetLength()/sizeof(unsigned short); |
| 437 » if (wsText == NULL) { | 379 if (wsText == NULL) { |
| 438 » » *size = len; | 380 *size = len; |
| 439 » » return; | 381 return; |
| 440 » } | 382 } |
| 441 | 383 |
| 442 » int real_size = len < *size ? len : *size; | 384 int real_size = len < *size ? len : *size; |
| 443 » if (real_size > 0) | 385 if (real_size > 0) |
| 444 » { | 386 { |
| 445 » » FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(u
nsigned short)),real_size*sizeof(unsigned short)); | 387 FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(unsigned
short)),real_size*sizeof(unsigned short)); |
| 446 » » bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); | 388 bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); |
| 447 » } | 389 } |
| 448 » *size = real_size; | 390 *size = real_size; |
| 449 } | 391 } |
| 450 DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, FPDF_WIDGET hWi
dget, FPDF_WIDESTRING wsText, FPDF_DWORD size) | 392 DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, FPDF_WIDGET hWi
dget, FPDF_WIDESTRING wsText, FPDF_DWORD size) |
| 451 { | 393 { |
| 452 » if (NULL == hWidget || NULL == document) | 394 if (NULL == hWidget || NULL == document) |
| 453 » » return; | 395 return; |
| 454 | 396 |
| 455 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 397 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 456 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 398 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType(
) != XFA_DOCTYPE_Static) |
| 457 » » return; | 399 return; |
| 458 | 400 |
| 459 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 401 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->
GetMenuHandler(); |
| 460 » if (pXFAMenuHander == NULL) | 402 if (pXFAMenuHander == NULL) |
| 461 » » return; | 403 return; |
| 462 | 404 |
| 463 » CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size); | 405 CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size); |
| 464 » pXFAMenuHander->Paste((IXFA_Widget*)hWidget, wstr); | 406 pXFAMenuHander->Paste((IXFA_Widget*)hWidget, wstr); |
| 465 | 407 |
| 466 } | 408 } |
| 467 DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget, float x, float y, FPDF_BYTESTRING bsText) | 409 DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget, float x, float y, FPDF_BYTESTRING bsText) |
| 468 { | 410 { |
| 469 » if (NULL == hWidget || NULL == document) | 411 if (NULL == hWidget || NULL == document) |
| 470 » » return; | 412 return; |
| 471 | 413 |
| 472 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 414 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 473 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 415 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType(
) != XFA_DOCTYPE_Static) |
| 474 » » return; | 416 return; |
| 475 | 417 |
| 476 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 418 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->
GetMenuHandler(); |
| 477 » if (pXFAMenuHander == NULL) | 419 if (pXFAMenuHander == NULL) |
| 478 » » return; | 420 return; |
| 479 | 421 |
| 480 » CFX_PointF ptPopup; | 422 CFX_PointF ptPopup; |
| 481 » ptPopup.x = x; | 423 ptPopup.x = x; |
| 482 » ptPopup.y = y; | 424 ptPopup.y = y; |
| 483 » CFX_ByteStringC bs(bsText); | 425 CFX_ByteStringC bs(bsText); |
| 484 » pXFAMenuHander->ReplaceSpellCheckWord((IXFA_Widget*)hWidget,ptPopup,bs); | 426 pXFAMenuHander->ReplaceSpellCheckWord((IXFA_Widget*)hWidget,ptPopup,bs); |
| 485 | 427 |
| 486 } | 428 } |
| 487 DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FP
DF_WIDGET hWidget, float x, float y, FPDF_STRINGHANDLE* stringHandle) | 429 DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FP
DF_WIDGET hWidget, float x, float y, FPDF_STRINGHANDLE* stringHandle) |
| 488 { | 430 { |
| 489 » if (NULL == hWidget || NULL == document) | 431 if (NULL == hWidget || NULL == document) |
| 490 » » return; | 432 return; |
| 491 | 433 |
| 492 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 434 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
| 493 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 435 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType(
) != XFA_DOCTYPE_Static) |
| 494 » » return; | 436 return; |
| 495 | 437 |
| 496 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 438 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->
GetMenuHandler(); |
| 497 » if (pXFAMenuHander == NULL) | 439 if (pXFAMenuHander == NULL) |
| 498 » » return; | 440 return; |
| 499 | 441 |
| 500 » CFX_ByteStringArray* sSuggestWords = FX_NEW CFX_ByteStringArray; | 442 CFX_ByteStringArray* sSuggestWords = FX_NEW CFX_ByteStringArray; |
| 501 » CFX_PointF ptPopup; | 443 CFX_PointF ptPopup; |
| 502 » ptPopup.x = x; | 444 ptPopup.x = x; |
| 503 » ptPopup.y = y; | 445 ptPopup.y = y; |
| 504 » pXFAMenuHander->GetSuggestWords((IXFA_Widget*)hWidget, ptPopup, *sSugges
tWords); | 446 pXFAMenuHander->GetSuggestWords((IXFA_Widget*)hWidget, ptPopup, *sSuggestWor
ds); |
| 505 » *stringHandle = (FPDF_STRINGHANDLE)sSuggestWords; | 447 *stringHandle = (FPDF_STRINGHANDLE)sSuggestWords; |
| 506 } | 448 } |
| 507 DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle) | 449 DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle) |
| 508 { | 450 { |
| 509 » if (stringHandle == NULL) | 451 if (stringHandle == NULL) |
| 510 » » return -1; | 452 return -1; |
| 511 » CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; | 453 CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; |
| 512 » return sSuggestWords->GetSize(); | 454 return sSuggestWords->GetSize(); |
| 513 } | 455 } |
| 514 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE
stringHandle, int index, FPDF_BYTESTRING bsText, FPDF_DWORD* size) | 456 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE
stringHandle, int index, FPDF_BYTESTRING bsText, FPDF_DWORD* size) |
| 515 { | 457 { |
| 516 » if (stringHandle == NULL || size == NULL) | 458 if (stringHandle == NULL || size == NULL) |
| 517 » » return FALSE; | 459 return FALSE; |
| 518 » int count = FPDF_StringHandleCounts(stringHandle); | 460 int count = FPDF_StringHandleCounts(stringHandle); |
| 519 » if (index < 0|| index >= count) | 461 if (index < 0|| index >= count) |
| 520 » » return FALSE; | 462 return FALSE; |
| 521 | 463 |
| 522 » CFX_ByteStringArray sSuggestWords = *(CFX_ByteStringArray*)stringHandle; | 464 CFX_ByteStringArray sSuggestWords = *(CFX_ByteStringArray*)stringHandle; |
| 523 » int len = sSuggestWords[index].GetLength(); | 465 int len = sSuggestWords[index].GetLength(); |
| 524 | 466 |
| 525 » if (bsText == NULL) { | 467 if (bsText == NULL) { |
| 526 » » *size = len; | 468 *size = len; |
| 527 » » return TRUE; | 469 return TRUE; |
| 528 » } | 470 } |
| 529 | 471 |
| 530 » int real_size = len < *size ? len : *size; | 472 int real_size = len < *size ? len : *size; |
| 531 » if (real_size > 0) | 473 if (real_size > 0) |
| 532 » » FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(sSuggestWords[index
]), real_size); | 474 FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(sSuggestWords[index]), real
_size); |
| 533 » *size = real_size; | 475 *size = real_size; |
| 534 | 476 |
| 535 » return TRUE; | 477 return TRUE; |
| 536 } | 478 } |
| 537 DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle) | 479 DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle) |
| 538 { | 480 { |
| 539 » if (stringHandle == NULL) | 481 if (stringHandle == NULL) |
| 540 » » return; | 482 return; |
| 541 » CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; | 483 CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; |
| 542 » delete sSuggestWords; | 484 delete sSuggestWords; |
| 543 } | 485 } |
| 544 | 486 |
| 545 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringH
andle, FPDF_BYTESTRING bsText, FPDF_DWORD size) | 487 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringH
andle, FPDF_BYTESTRING bsText, FPDF_DWORD size) |
| 546 { | 488 { |
| 547 » if (stringHandle == NULL || bsText == NULL || size <= 0) | 489 if (stringHandle == NULL || bsText == NULL || size <= 0) |
| 548 » » return FALSE; | 490 return FALSE; |
| 549 | 491 |
| 550 » CFX_ByteStringArray* stringArr = (CFX_ByteStringArray*)stringHandle; | 492 CFX_ByteStringArray* stringArr = (CFX_ByteStringArray*)stringHandle; |
| 551 » CFX_ByteString bsStr(bsText, size); | 493 CFX_ByteString bsStr(bsText, size); |
| 552 | 494 |
| 553 » stringArr->Add(bsStr); | 495 stringArr->Add(bsStr); |
| 554 » return TRUE; | 496 return TRUE; |
| 555 } | 497 } |
| 556 | 498 |
| 557 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
int fieldType, unsigned long color) | 499 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
int fieldType, unsigned long color) |
| 558 { | 500 { |
| 559 » if (!hHandle) | 501 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
| 560 » » return; | 502 pInterForm->SetHighlightColor(color, fieldType); |
| 561 //» CPDFDoc_Environment* pEnv = (CPDFDoc_Environment* )hHandle; | |
| 562 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | |
| 563 » if(pSDKDoc) | |
| 564 » { | |
| 565 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
| 566 » » { | |
| 567 » » » pInterForm->SetHighlightColor(color, fieldType); | |
| 568 » » } | |
| 569 | |
| 570 » } | |
| 571 | |
| 572 } | 503 } |
| 573 | 504 |
| 574 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle,
unsigned char alpha) | 505 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle,
unsigned char alpha) |
| 575 { | 506 { |
| 576 » if (!hHandle) | 507 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
| 577 » » return; | 508 pInterForm->SetHighlightAlpha(alpha); |
| 578 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | |
| 579 » if(pSDKDoc) | |
| 580 » { | |
| 581 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
| 582 » » » pInterForm->SetHighlightAlpha(alpha); | |
| 583 » } | |
| 584 } | 509 } |
| 585 | 510 |
| 586 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) | 511 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) |
| 587 { | 512 { |
| 588 » if (!hHandle) | 513 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
| 589 » » return; | 514 pInterForm->RemoveAllHighLight(); |
| 590 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | |
| 591 » if(pSDKDoc) | |
| 592 » { | |
| 593 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
| 594 » » » pInterForm->RemoveAllHighLight(); | |
| 595 » } | |
| 596 } | 515 } |
| 597 | 516 |
| 598 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan
dle) | 517 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan
dle) |
| 599 { | 518 { |
| 600 » if(!hHandle || !page) | 519 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) |
| 601 » » return; | 520 pPageView->SetValid(TRUE); |
| 602 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | |
| 603 » if(!pSDKDoc) | |
| 604 » » return; | |
| 605 » CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | |
| 606 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, TRUE); | |
| 607 » if(pPageView) | |
| 608 » { | |
| 609 » » pPageView->SetValid(TRUE); | |
| 610 » } | |
| 611 } | 521 } |
| 612 | 522 |
| 613 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH
andle) | 523 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH
andle) |
| 614 { | 524 { |
| 615 » if(!hHandle || !page) | 525 if (!hHandle || !page) |
| 616 » » return; | 526 return; |
| 617 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 527 |
| 618 » CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | 528 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(
); |
| 619 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); | 529 if (!pSDKDoc) |
| 620 » if(pPageView) | 530 return; |
| 621 » { | 531 |
| 622 » » pPageView->SetValid(FALSE); | 532 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; |
| 623 » » // ReMovePageView() takes care of the delete for us. | 533 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); |
| 624 » » pSDKDoc->ReMovePageView(pPage); | 534 if (pPageView) |
| 625 » } | 535 { |
| 626 } | 536 pPageView->SetValid(FALSE); |
| 537 // ReMovePageView() takes care of the delete for us. |
| 538 pSDKDoc->ReMovePageView(pPage); |
| 539 } |
| 540 } |
| 541 |
| 627 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) | 542 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) |
| 628 { | 543 { |
| 629 » if(!hHandle) | 544 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
| 630 » » return; | 545 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) |
| 631 » if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurr
entDoc()) | 546 pSDKDoc->ProcJavascriptFun(); |
| 632 » { | |
| 633 » » if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) | |
| 634 » » » pSDKDoc->ProcJavascriptFun(); | |
| 635 » } | |
| 636 } | 547 } |
| 637 | 548 |
| 638 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) | 549 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) |
| 639 { | 550 { |
| 640 » if(!hHandle) | 551 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
| 641 » » return; | 552 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) |
| 642 » if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurr
entDoc()) | 553 pSDKDoc->ProcOpenAction(); |
| 643 » { | 554 } |
| 644 » » if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) | 555 |
| 645 » » » pSDKDoc->ProcOpenAction(); | |
| 646 » } | |
| 647 } | |
| 648 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp
e) | 556 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp
e) |
| 649 { | 557 { |
| 650 » if(!hHandle) | 558 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
| 651 » » return; | 559 if (!pSDKDoc) |
| 652 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 560 return; |
| 653 » if(pSDKDoc) | 561 |
| 654 » { | 562 CPDF_Document* pDoc = pSDKDoc->GetDocument()->GetPDFDoc(); |
| 655 » » CPDF_Document* pDoc = pSDKDoc->GetDocument()->GetPDFDoc(); | 563 CPDF_Dictionary* pDic = pDoc->GetRoot(); |
| 656 » » CPDF_Dictionary* pDic = pDoc->GetRoot(); | 564 if (!pDic) |
| 657 » » if (!pDic) | 565 return; |
| 658 » » » return; | 566 CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA")); |
| 659 » » CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA")); | 567 if(aa.ActionExist((CPDF_AAction::AActionType)aaType)) |
| 660 | 568 { |
| 661 » » if(aa.ActionExist((CPDF_AAction::AActionType)aaType)) | 569 CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType); |
| 662 » » { | 570 CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Environment*)hHandle)-
>GetActionHander(); |
| 663 » » » CPDF_Action action = aa.GetAction((CPDF_AAction::AAction
Type)aaType); | 571 ASSERT(pActionHandler != NULL); |
| 664 » » » CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Enviro
nment*)hHandle)->GetActionHander(); | 572 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaT
ype, pSDKDoc); |
| 665 » » » ASSERT(pActionHandler != NULL); | 573 } |
| 666 » » » pActionHandler->DoAction_Document(action, (CPDF_AAction:
:AActionType)aaType, pSDKDoc); | 574 } |
| 667 » » } | 575 |
| 668 » } | |
| 669 } | |
| 670 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl
e, int aaType) | 576 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl
e, int aaType) |
| 671 { | 577 { |
| 672 » if(!hHandle || !page) | 578 if(!hHandle || !page) |
| 673 » » return; | 579 return; |
| 674 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 580 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(
); |
| 675 » CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | 581 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; |
| 676 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); | 582 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); |
| 677 » if(pPageView) | 583 if(pPageView) |
| 678 » { | 584 { |
| 679 » » CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv(); | 585 CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv(); |
| 680 » » ASSERT(pEnv != NULL); | 586 CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander(); |
| 681 | 587 CPDF_Dictionary *pPageDict = pPage->GetPDFPage()->m_pFormDict; |
| 682 » » CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander(); | 588 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA")); |
| 683 » » ASSERT(pActionHandler != NULL); | 589 |
| 684 | 590 FX_BOOL bExistOAAction = FALSE; |
| 685 » » if (!pPage->GetPDFPage()) | 591 FX_BOOL bExistCAAction = FALSE; |
| 686 » » » return; | 592 if (FPDFPAGE_AACTION_OPEN == aaType) |
| 687 » » CPDF_Dictionary *pPageDict = pPage->GetPDFPage()->m_pFormDict; | 593 { |
| 688 » » ASSERT(pPageDict != NULL); | 594 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage); |
| 689 | 595 if (bExistOAAction) |
| 690 » » CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA")); | 596 { |
| 691 | 597 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); |
| 692 » » FX_BOOL bExistOAAction = FALSE; | 598 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pS
DKDoc); |
| 693 » » FX_BOOL bExistCAAction = FALSE; | 599 } |
| 694 » » if (FPDFPAGE_AACTION_OPEN == aaType) | 600 } |
| 695 » » { | 601 else |
| 696 » » » bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage); | 602 { |
| 697 » » » if (bExistOAAction) | 603 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage); |
| 698 » » » { | 604 if (bExistCAAction) |
| 699 » » » » CPDF_Action action = aa.GetAction(CPDF_AAction::
OpenPage); | 605 { |
| 700 » » » » pActionHandler->DoAction_Page(action, CPDF_AActi
on::OpenPage, pSDKDoc); | 606 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
| 701 » » » } | 607 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, p
SDKDoc); |
| 702 » » } | 608 } |
| 703 » » else | 609 } |
| 704 » » { | 610 } |
| 705 » » » bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage)
; | 611 } |
| 706 » » » if (bExistCAAction) | |
| 707 » » » { | |
| 708 » » » » CPDF_Action action = aa.GetAction(CPDF_AAction::
ClosePage); | |
| 709 » » » » pActionHandler->DoAction_Page(action, CPDF_AActi
on::ClosePage, pSDKDoc); | |
| 710 » » » } | |
| 711 » » } | |
| 712 » } | |
| 713 } | |
| 714 | |
| 715 | |
| OLD | NEW |