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 "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" |
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" |
13 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" | 13 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" |
14 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" | 14 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" |
15 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" | 15 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" |
16 #include "fpdfsdk/include/fsdk_define.h" | 16 #include "fpdfsdk/include/fsdk_define.h" |
17 #include "fpdfsdk/include/fsdk_mgr.h" | 17 #include "fpdfsdk/include/fsdk_mgr.h" |
18 #include "fpdfsdk/javascript/ijs_runtime.h" | 18 #include "fpdfsdk/javascript/ijs_runtime.h" |
19 #include "public/fpdf_formfill.h" | 19 #include "public/fpdf_formfill.h" |
| 20 #include "xfa/fxfa/include/cxfa_eventparam.h" |
20 #include "xfa/fxfa/include/xfa_ffapp.h" | 21 #include "xfa/fxfa/include/xfa_ffapp.h" |
21 #include "xfa/fxfa/include/xfa_ffdoc.h" | 22 #include "xfa/fxfa/include/xfa_ffdoc.h" |
22 #include "xfa/fxfa/include/xfa_ffdocview.h" | 23 #include "xfa/fxfa/include/xfa_ffdocview.h" |
23 #include "xfa/fxfa/include/xfa_ffpageview.h" | 24 #include "xfa/fxfa/include/xfa_ffpageview.h" |
24 #include "xfa/fxfa/include/xfa_ffwidget.h" | 25 #include "xfa/fxfa/include/xfa_ffwidget.h" |
| 26 #include "xfa/fxfa/include/xfa_ffwidgethandler.h" |
25 | 27 |
26 #define IDS_XFA_Validate_Input \ | 28 #define IDS_XFA_Validate_Input \ |
27 "At least one required field was empty. Please fill in the required " \ | 29 "At least one required field was empty. Please fill in the required " \ |
28 "fields\r\n(highlighted) before continuing." | 30 "fields\r\n(highlighted) before continuing." |
29 | 31 |
30 // submit | 32 // submit |
31 #define FXFA_CONFIG 0x00000001 | 33 #define FXFA_CONFIG 0x00000001 |
32 #define FXFA_TEMPLATE 0x00000010 | 34 #define FXFA_TEMPLATE 0x00000010 |
33 #define FXFA_LOCALESET 0x00000100 | 35 #define FXFA_LOCALESET 0x00000100 |
34 #define FXFA_DATASETS 0x00001000 | 36 #define FXFA_DATASETS 0x00001000 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 pdfRect.right = fxRectF.right(); | 233 pdfRect.right = fxRectF.right(); |
232 pdfRect.bottom = fxRectF.top; | 234 pdfRect.bottom = fxRectF.top; |
233 } | 235 } |
234 | 236 |
235 void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) { | 237 void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) { |
236 if (hDoc == m_pXFADoc && m_pSDKDoc) { | 238 if (hDoc == m_pXFADoc && m_pSDKDoc) { |
237 m_pSDKDoc->SetChangeMark(); | 239 m_pSDKDoc->SetChangeMark(); |
238 } | 240 } |
239 } | 241 } |
240 | 242 |
241 FX_BOOL CPDFXFA_Document::GetChangeMark(CXFA_FFDoc* hDoc) { | |
242 if (hDoc == m_pXFADoc && m_pSDKDoc) | |
243 return m_pSDKDoc->GetChangeMark(); | |
244 return FALSE; | |
245 } | |
246 | |
247 void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, | 243 void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, |
248 const CFX_RectF& rt, | 244 const CFX_RectF& rt, |
249 uint32_t dwFlags /* = 0 */) { | 245 uint32_t dwFlags /* = 0 */) { |
250 if (!m_pXFADoc || !m_pSDKDoc) | 246 if (!m_pXFADoc || !m_pSDKDoc) |
251 return; | 247 return; |
252 | 248 |
253 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 249 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
254 return; | 250 return; |
255 | 251 |
256 CFX_FloatRect rcPage; | 252 CFX_FloatRect rcPage; |
257 FXRect2PDFRect(rt, rcPage); | 253 FXRect2PDFRect(rt, rcPage); |
258 | 254 |
259 CPDFXFA_Page* pPage = GetPage(pPageView); | 255 CPDFXFA_Page* pPage = GetPage(pPageView); |
260 if (!pPage) | 256 if (!pPage) |
261 return; | 257 return; |
262 | 258 |
263 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 259 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
264 if (!pEnv) | 260 if (!pEnv) |
265 return; | 261 return; |
266 | 262 |
267 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, | 263 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, |
268 rcPage.right, rcPage.top); | 264 rcPage.right, rcPage.top); |
269 } | 265 } |
270 | 266 |
271 void CPDFXFA_Document::InvalidateRect(CXFA_FFWidget* hWidget, | |
272 uint32_t dwFlags /* = 0 */) { | |
273 if (!hWidget) | |
274 return; | |
275 | |
276 if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) | |
277 return; | |
278 | |
279 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | |
280 return; | |
281 | |
282 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); | |
283 if (!pWidgetHandler) | |
284 return; | |
285 | |
286 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | |
287 if (!pPageView) | |
288 return; | |
289 | |
290 CFX_RectF rect; | |
291 hWidget->GetRect(rect); | |
292 InvalidateRect(pPageView, rect, dwFlags); | |
293 } | |
294 | |
295 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, | 267 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, |
296 FX_BOOL bVisible, | 268 FX_BOOL bVisible, |
297 const CFX_RectF* pRtAnchor) { | 269 const CFX_RectF* pRtAnchor) { |
298 if (!hWidget || !pRtAnchor || !m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) | 270 if (!hWidget || !pRtAnchor || !m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) |
299 return; | 271 return; |
300 | 272 |
301 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 273 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
302 return; | 274 return; |
303 | 275 |
304 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); | 276 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 517 |
546 CPDFXFA_Page* pXFAPage = GetPage(pPageView); | 518 CPDFXFA_Page* pXFAPage = GetPage(pPageView); |
547 if (!pXFAPage) | 519 if (!pXFAPage) |
548 return; | 520 return; |
549 | 521 |
550 CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage); | 522 CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage); |
551 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) | 523 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) |
552 pSdkPageView->DeleteAnnot(pAnnot); | 524 pSdkPageView->DeleteAnnot(pAnnot); |
553 } | 525 } |
554 | 526 |
| 527 FX_BOOL CPDFXFA_Document::RenderCustomWidget(CXFA_FFWidget* hWidget, |
| 528 CFX_Graphics* pGS, |
| 529 CFX_Matrix* pMatrix, |
| 530 const CFX_RectF& rtUI) { |
| 531 return FALSE; |
| 532 } |
| 533 |
555 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { | 534 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { |
556 if (hDoc == m_pXFADoc && m_pSDKDoc) | 535 if (hDoc == m_pXFADoc && m_pSDKDoc) |
557 return GetPageCount(); | 536 return GetPageCount(); |
558 return 0; | 537 return 0; |
559 } | 538 } |
560 | 539 |
561 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { | 540 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { |
562 if (hDoc != m_pXFADoc || !m_pSDKDoc) | 541 if (hDoc != m_pXFADoc || !m_pSDKDoc) |
563 return -1; | 542 return -1; |
564 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 543 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 } | 761 } |
783 | 762 |
784 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( | 763 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( |
785 pEnv->GetFormFillInfo()->m_pJsPlatform, | 764 pEnv->GetFormFillInfo()->m_pJsPlatform, |
786 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, | 765 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, |
787 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, | 766 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, |
788 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, | 767 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, |
789 dwOptions & XFA_PRINTOPT_PrintAnnot); | 768 dwOptions & XFA_PRINTOPT_PrintAnnot); |
790 } | 769 } |
791 | 770 |
| 771 int32_t CPDFXFA_Document::AbsPageCountInBatch(CXFA_FFDoc* hDoc) { |
| 772 return 0; |
| 773 } |
| 774 |
| 775 int32_t CPDFXFA_Document::AbsPageInBatch(CXFA_FFDoc* hDoc, |
| 776 CXFA_FFWidget* hWidget) { |
| 777 return 0; |
| 778 } |
| 779 |
| 780 int32_t CPDFXFA_Document::SheetCountInBatch(CXFA_FFDoc* hDoc) { |
| 781 return 0; |
| 782 } |
| 783 |
| 784 int32_t CPDFXFA_Document::SheetInBatch(CXFA_FFDoc* hDoc, |
| 785 CXFA_FFWidget* hWidget) { |
| 786 return 0; |
| 787 } |
| 788 |
| 789 int32_t CPDFXFA_Document::Verify(CXFA_FFDoc* hDoc, |
| 790 CXFA_Node* pSigNode, |
| 791 FX_BOOL bUsed) { |
| 792 return 0; |
| 793 } |
| 794 |
| 795 FX_BOOL CPDFXFA_Document::Sign(CXFA_FFDoc* hDoc, |
| 796 CXFA_NodeList* pNodeList, |
| 797 const CFX_WideStringC& wsExpression, |
| 798 const CFX_WideStringC& wsXMLIdent, |
| 799 const CFX_WideStringC& wsValue, |
| 800 FX_BOOL bUsed) { |
| 801 return 0; |
| 802 } |
| 803 |
| 804 CXFA_NodeList* CPDFXFA_Document::Enumerate(CXFA_FFDoc* hDoc) { |
| 805 return 0; |
| 806 } |
| 807 |
| 808 FX_BOOL CPDFXFA_Document::Clear(CXFA_FFDoc* hDoc, |
| 809 CXFA_Node* pSigNode, |
| 810 FX_BOOL bCleared) { |
| 811 return 0; |
| 812 } |
| 813 |
792 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { | 814 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { |
793 if (hDoc != m_pXFADoc) | 815 if (hDoc != m_pXFADoc) |
794 return; | 816 return; |
795 | 817 |
796 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 818 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
797 if (!pEnv) | 819 if (!pEnv) |
798 return; | 820 return; |
799 | 821 |
800 pEnv->FFI_GetURL(this, wsDocURL); | 822 pEnv->FFI_GetURL(this, wsDocURL); |
801 } | 823 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { | 920 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { |
899 if (!_NotifySubmit(TRUE) || !m_pXFADocView) | 921 if (!_NotifySubmit(TRUE) || !m_pXFADocView) |
900 return FALSE; | 922 return FALSE; |
901 m_pXFADocView->UpdateDocView(); | 923 m_pXFADocView->UpdateDocView(); |
902 | 924 |
903 FX_BOOL ret = _SubmitData(hDoc, submit); | 925 FX_BOOL ret = _SubmitData(hDoc, submit); |
904 _NotifySubmit(FALSE); | 926 _NotifySubmit(FALSE); |
905 return ret; | 927 return ret; |
906 } | 928 } |
907 | 929 |
| 930 FX_BOOL CPDFXFA_Document::CheckWord(CXFA_FFDoc* hDoc, |
| 931 const CFX_ByteStringC& sWord) { |
| 932 return FALSE; |
| 933 } |
| 934 |
| 935 FX_BOOL CPDFXFA_Document::GetSuggestWords( |
| 936 CXFA_FFDoc* hDoc, |
| 937 const CFX_ByteStringC& sWord, |
| 938 std::vector<CFX_ByteString>& sSuggest) { |
| 939 return FALSE; |
| 940 } |
| 941 |
908 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, | 942 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, |
909 const CFX_WideString& wsLink) { | 943 const CFX_WideString& wsLink) { |
910 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 944 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
911 if (!pEnv) | 945 if (!pEnv) |
912 return FALSE; | 946 return FALSE; |
913 CFX_ByteString bs = wsLink.UTF16LE_Encode(); | 947 CFX_ByteString bs = wsLink.UTF16LE_Encode(); |
914 int len = bs.GetLength() / sizeof(unsigned short); | 948 int len = bs.GetLength() / sizeof(unsigned short); |
915 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( | 949 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( |
916 0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb"); | 950 0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb"); |
917 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 951 bs.ReleaseBuffer(len * sizeof(unsigned short)); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 return FALSE; | 1269 return FALSE; |
1236 | 1270 |
1237 if (!m_pJSContext) { | 1271 if (!m_pJSContext) { |
1238 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc); | 1272 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc); |
1239 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); | 1273 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); |
1240 } | 1274 } |
1241 | 1275 |
1242 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, | 1276 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, |
1243 pValue); | 1277 pValue); |
1244 } | 1278 } |
| 1279 |
| 1280 CPDF_Document* CPDFXFA_Document::OpenPDF(CXFA_FFDoc* hDoc, |
| 1281 IFX_FileRead* pFile, |
| 1282 FX_BOOL bTakeOverFile) { |
| 1283 return nullptr; |
| 1284 } |
OLD | NEW |