Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp

Issue 1857893002: Cleanup the FF Handler proxy methods. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfsave.cpp ('k') | fpdfsdk/fsdk_annothandler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
11 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" 11 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
12 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" 12 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
13 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" 13 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
14 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" 14 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
15 #include "fpdfsdk/include/fsdk_define.h" 15 #include "fpdfsdk/include/fsdk_define.h"
16 #include "fpdfsdk/include/fsdk_mgr.h" 16 #include "fpdfsdk/include/fsdk_mgr.h"
17 #include "fpdfsdk/javascript/ijs_runtime.h" 17 #include "fpdfsdk/javascript/ijs_runtime.h"
18 #include "public/fpdf_formfill.h" 18 #include "public/fpdf_formfill.h"
19 #include "xfa/include/fxfa/xfa_ffapp.h" 19 #include "xfa/include/fxfa/xfa_ffapp.h"
20 #include "xfa/include/fxfa/xfa_ffdoc.h" 20 #include "xfa/include/fxfa/xfa_ffdoc.h"
21 #include "xfa/include/fxfa/xfa_ffdocview.h" 21 #include "xfa/include/fxfa/xfa_ffdocview.h"
22 #include "xfa/include/fxfa/xfa_ffpageview.h" 22 #include "xfa/include/fxfa/xfa_ffpageview.h"
23 #include "xfa/include/fxfa/xfa_ffwidget.h"
23 24
24 #define IDS_XFA_Validate_Input \ 25 #define IDS_XFA_Validate_Input \
25 "At least one required field was empty. Please fill in the required " \ 26 "At least one required field was empty. Please fill in the required " \
26 "fields\r\n(highlighted) before continuing." 27 "fields\r\n(highlighted) before continuing."
27 28
28 // submit 29 // submit
29 #define FXFA_CONFIG 0x00000001 30 #define FXFA_CONFIG 0x00000001
30 #define FXFA_TEMPLATE 0x00000010 31 #define FXFA_TEMPLATE 0x00000010
31 #define FXFA_LOCALESET 0x00000100 32 #define FXFA_LOCALESET 0x00000100
32 #define FXFA_DATASETS 0x00001000 33 #define FXFA_DATASETS 0x00001000
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 SetLastError(FPDF_ERR_XFALOAD); 98 SetLastError(FPDF_ERR_XFALOAD);
98 return FALSE; 99 return FALSE;
99 } 100 }
100 101
101 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); 102 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler();
102 if (!pDocHandler) { 103 if (!pDocHandler) {
103 SetLastError(FPDF_ERR_XFALOAD); 104 SetLastError(FPDF_ERR_XFALOAD);
104 return FALSE; 105 return FALSE;
105 } 106 }
106 107
107 pDocHandler->StartLoad(m_pXFADoc); 108 m_pXFADoc->StartLoad();
108 int iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL); 109 int iStatus = m_pXFADoc->DoLoad(nullptr);
109 if (iStatus != XFA_PARSESTATUS_Done) { 110 if (iStatus != XFA_PARSESTATUS_Done) {
110 CloseXFADoc(pDocHandler); 111 CloseXFADoc(pDocHandler);
111 SetLastError(FPDF_ERR_XFALOAD); 112 SetLastError(FPDF_ERR_XFALOAD);
112 return FALSE; 113 return FALSE;
113 } 114 }
114 pDocHandler->StopLoad(m_pXFADoc); 115 m_pXFADoc->StopLoad();
115 pDocHandler->SetJSERuntime(m_pXFADoc, m_pApp->GetJSERuntime()); 116 m_pXFADoc->GetXFADoc()->InitScriptContext(m_pApp->GetJSERuntime());
116 117
117 if (pDocHandler->GetDocType(m_pXFADoc) == XFA_DOCTYPE_Dynamic) 118 if (m_pXFADoc->GetDocType() == XFA_DOCTYPE_Dynamic)
118 m_iDocType = DOCTYPE_DYNAMIC_XFA; 119 m_iDocType = DOCTYPE_DYNAMIC_XFA;
119 else 120 else
120 m_iDocType = DOCTYPE_STATIC_XFA; 121 m_iDocType = DOCTYPE_STATIC_XFA;
121 122
122 m_pXFADocView = pDocHandler->CreateDocView(m_pXFADoc, XFA_DOCVIEW_View); 123 m_pXFADocView = m_pXFADoc->CreateDocView(XFA_DOCVIEW_View);
123 if (m_pXFADocView->StartLayout() < 0) { 124 if (m_pXFADocView->StartLayout() < 0) {
124 CloseXFADoc(pDocHandler); 125 CloseXFADoc(pDocHandler);
125 SetLastError(FPDF_ERR_XFALAYOUT); 126 SetLastError(FPDF_ERR_XFALAYOUT);
126 return FALSE; 127 return FALSE;
127 } 128 }
128 129
129 m_pXFADocView->DoLayout(NULL); 130 m_pXFADocView->DoLayout(NULL);
130 m_pXFADocView->StopLayout(); 131 m_pXFADocView->StopLayout();
131 m_nLoadStatus = FXFA_LOADSTATUS_LOADED; 132 m_nLoadStatus = FXFA_LOADSTATUS_LOADED;
132 133
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) 269 if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView)
269 return; 270 return;
270 271
271 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 272 if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
272 return; 273 return;
273 274
274 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); 275 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
275 if (!pWidgetHandler) 276 if (!pWidgetHandler)
276 return; 277 return;
277 278
278 CXFA_FFPageView* pPageView = pWidgetHandler->GetPageView(hWidget); 279 CXFA_FFPageView* pPageView = hWidget->GetPageView();
279 if (!pPageView) 280 if (!pPageView)
280 return; 281 return;
281 282
282 CFX_RectF rect; 283 CFX_RectF rect;
283 pWidgetHandler->GetRect(hWidget, rect); 284 hWidget->GetRect(rect);
284 InvalidateRect(pPageView, rect, dwFlags); 285 InvalidateRect(pPageView, rect, dwFlags);
285 } 286 }
286 287
287 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, 288 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget,
288 FX_BOOL bVisible, 289 FX_BOOL bVisible,
289 const CFX_RectF* pRtAnchor) { 290 const CFX_RectF* pRtAnchor) {
290 if (!hWidget || pRtAnchor == NULL) 291 if (!hWidget || pRtAnchor == NULL)
291 return; 292 return;
292 293
293 if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) 294 if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView)
294 return; 295 return;
295 296
296 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 297 if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
297 return; 298 return;
298 299
299 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); 300 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
300 if (!pWidgetHandler) 301 if (!pWidgetHandler)
301 return; 302 return;
302 303
303 CXFA_FFPageView* pPageView = pWidgetHandler->GetPageView(hWidget); 304 CXFA_FFPageView* pPageView = hWidget->GetPageView();
304 if (!pPageView) 305 if (!pPageView)
305 return; 306 return;
306 307
307 CPDFXFA_Page* pPage = GetPage(pPageView); 308 CPDFXFA_Page* pPage = GetPage(pPageView);
308 309
309 if (pPage == NULL) 310 if (pPage == NULL)
310 return; 311 return;
311 312
312 CFX_FloatRect rcCaret; 313 CFX_FloatRect rcCaret;
313 FXRect2PDFRect(*pRtAnchor, rcCaret); 314 FXRect2PDFRect(*pRtAnchor, rcCaret);
314 315
315 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 316 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
316 if (!pEnv) 317 if (!pEnv)
317 return; 318 return;
318 319
319 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, 320 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top,
320 rcCaret.right, rcCaret.bottom); 321 rcCaret.right, rcCaret.bottom);
321 } 322 }
322 323
323 FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, 324 FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget,
324 FX_FLOAT fMinPopup, 325 FX_FLOAT fMinPopup,
325 FX_FLOAT fMaxPopup, 326 FX_FLOAT fMaxPopup,
326 const CFX_RectF& rtAnchor, 327 const CFX_RectF& rtAnchor,
327 CFX_RectF& rtPopup) { 328 CFX_RectF& rtPopup) {
328 if (NULL == hWidget) { 329 if (!hWidget)
329 return FALSE;
330 }
331 CXFA_FFPageView* pXFAPageView =
332 m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget);
333 if (NULL == pXFAPageView) {
334 return FALSE;
335 }
336 CPDFXFA_Page* pPage = GetPage(pXFAPageView);
337 if (pPage == NULL)
338 return FALSE; 330 return FALSE;
339 331
340 CXFA_WidgetAcc* pWidgetAcc = 332 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
341 m_pXFADocView->GetWidgetHandler()->GetDataAcc(hWidget); 333 if (!pXFAPageView)
334 return FALSE;
342 335
336 CPDFXFA_Page* pPage = GetPage(pXFAPageView);
337 if (!pPage)
338 return FALSE;
339
340 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc();
343 int nRotate = 0; 341 int nRotate = 0;
344 #ifdef PDF_ENABLE_XFA 342 #ifdef PDF_ENABLE_XFA
345 nRotate = pWidgetAcc->GetRotate(); 343 nRotate = pWidgetAcc->GetRotate();
346 #endif 344 #endif
347 345
348 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 346 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
349 if (pEnv == NULL) 347 if (!pEnv)
350 return FALSE; 348 return FALSE;
351 FS_RECTF pageViewRect; 349 FS_RECTF pageViewRect;
352 pEnv->FFI_GetPageViewRect(pPage, pageViewRect); 350 pEnv->FFI_GetPageViewRect(pPage, pageViewRect);
353 351
354 CFX_FloatRect rcAnchor; 352 CFX_FloatRect rcAnchor;
355 353
356 rcAnchor.left = rtAnchor.left; 354 rcAnchor.left = rtAnchor.left;
357 rcAnchor.top = rtAnchor.bottom(); 355 rcAnchor.top = rtAnchor.bottom();
358 rcAnchor.right = rtAnchor.right(); 356 rcAnchor.right = rtAnchor.right();
359 rcAnchor.bottom = rtAnchor.top; 357 rcAnchor.bottom = rtAnchor.top;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 default: 448 default:
451 break; 449 break;
452 } 450 }
453 451
454 return TRUE; 452 return TRUE;
455 } 453 }
456 454
457 FX_BOOL CPDFXFA_Document::PopupMenu(CXFA_FFWidget* hWidget, 455 FX_BOOL CPDFXFA_Document::PopupMenu(CXFA_FFWidget* hWidget,
458 CFX_PointF ptPopup, 456 CFX_PointF ptPopup,
459 const CFX_RectF* pRectExclude) { 457 const CFX_RectF* pRectExclude) {
460 if (NULL == hWidget) { 458 if (!hWidget)
461 return FALSE; 459 return FALSE;
462 } 460
463 CXFA_FFPageView* pXFAPageView = 461 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
464 m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget); 462 if (!pXFAPageView)
465 if (pXFAPageView == NULL)
466 return FALSE; 463 return FALSE;
464
467 CPDFXFA_Page* pPage = GetPage(pXFAPageView); 465 CPDFXFA_Page* pPage = GetPage(pXFAPageView);
468 466 if (!pPage)
469 if (pPage == NULL)
470 return FALSE; 467 return FALSE;
471 468
472 int menuFlag = 0; 469 int menuFlag = 0;
473 470
474 CXFA_FFMenuHandler* pXFAMenuHander = m_pApp->GetXFAApp()->GetMenuHandler(); 471 if (hWidget->CanUndo())
475 if (pXFAMenuHander->CanUndo(hWidget))
476 menuFlag |= FXFA_MEMU_UNDO; 472 menuFlag |= FXFA_MEMU_UNDO;
477 if (pXFAMenuHander->CanRedo(hWidget)) 473 if (hWidget->CanRedo())
478 menuFlag |= FXFA_MEMU_REDO; 474 menuFlag |= FXFA_MEMU_REDO;
479 if (pXFAMenuHander->CanPaste(hWidget)) 475 if (hWidget->CanPaste())
480 menuFlag |= FXFA_MEMU_PASTE; 476 menuFlag |= FXFA_MEMU_PASTE;
481 if (pXFAMenuHander->CanCopy(hWidget)) 477 if (hWidget->CanCopy())
482 menuFlag |= FXFA_MEMU_COPY; 478 menuFlag |= FXFA_MEMU_COPY;
483 if (pXFAMenuHander->CanCut(hWidget)) 479 if (hWidget->CanCut())
484 menuFlag |= FXFA_MEMU_CUT; 480 menuFlag |= FXFA_MEMU_CUT;
485 if (pXFAMenuHander->CanSelectAll(hWidget)) 481 if (hWidget->CanSelectAll())
486 menuFlag |= FXFA_MEMU_SELECTALL; 482 menuFlag |= FXFA_MEMU_SELECTALL;
487 483
488 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 484 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
489 if (pEnv == NULL) 485 return pEnv && pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL);
490 return FALSE;
491
492 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL);
493 } 486 }
494 487
495 void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView, 488 void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView,
496 uint32_t dwFlags) { 489 uint32_t dwFlags) {
497 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 490 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
498 if (!pEnv) 491 if (!pEnv)
499 return; 492 return;
500 493
501 if (m_nLoadStatus != FXFA_LOADSTATUS_LOADING && 494 if (m_nLoadStatus != FXFA_LOADSTATUS_LOADING &&
502 m_nLoadStatus != FXFA_LOADSTATUS_CLOSING && 495 m_nLoadStatus != FXFA_LOADSTATUS_CLOSING &&
(...skipping 30 matching lines...) Expand all
533 uint32_t dwEvent, 526 uint32_t dwEvent,
534 void* pParam, 527 void* pParam,
535 void* pAdditional) { 528 void* pAdditional) {
536 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) 529 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget)
537 return; 530 return;
538 531
539 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 532 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
540 if (!pEnv) 533 if (!pEnv)
541 return; 534 return;
542 535
543 CXFA_FFPageView* pPageView = 536 CXFA_FFPageView* pPageView = hWidget->GetPageView();
544 m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget); 537 if (!pPageView)
545 if (pPageView == NULL)
546 return; 538 return;
547 539
548 CPDFXFA_Page* pXFAPage = GetPage(pPageView); 540 CPDFXFA_Page* pXFAPage = GetPage(pPageView);
549 if (pXFAPage == NULL) 541 if (!pXFAPage)
550 return; 542 return;
551 543
552 CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage); 544 CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage);
553 if (dwEvent == XFA_WIDGETEVENT_PostAdded) { 545 if (dwEvent == XFA_WIDGETEVENT_PostAdded) {
554 pSdkPageView->AddAnnot(hWidget); 546 pSdkPageView->AddAnnot(hWidget);
555
556 } else if (dwEvent == XFA_WIDGETEVENT_PreRemoved) { 547 } else if (dwEvent == XFA_WIDGETEVENT_PreRemoved) {
557 CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget); 548 CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget);
558 if (pAnnot) { 549 if (pAnnot)
559 pSdkPageView->DeleteAnnot(pAnnot); 550 pSdkPageView->DeleteAnnot(pAnnot);
560 }
561 } 551 }
562 } 552 }
563 553
564 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { 554 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) {
565 if (hDoc == m_pXFADoc && m_pSDKDoc) { 555 if (hDoc == m_pXFADoc && m_pSDKDoc)
566 return GetPageCount(); 556 return GetPageCount();
567 }
568 return 0; 557 return 0;
569 } 558 }
559
570 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { 560 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) {
571 if (hDoc != m_pXFADoc || !m_pSDKDoc) 561 if (hDoc != m_pXFADoc || !m_pSDKDoc)
572 return -1; 562 return -1;
573 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 563 if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
574 return -1; 564 return -1;
575 565
576 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 566 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
577 if (pEnv == NULL) 567 if (!pEnv)
578 return -1; 568 return -1;
579 569
580 return pEnv->FFI_GetCurrentPageIndex(this); 570 return pEnv->FFI_GetCurrentPageIndex(this);
581 } 571 }
572
582 void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { 573 void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) {
583 if (hDoc != m_pXFADoc || !m_pSDKDoc || m_iDocType != DOCTYPE_DYNAMIC_XFA || 574 if (hDoc != m_pXFADoc || !m_pSDKDoc || m_iDocType != DOCTYPE_DYNAMIC_XFA ||
584 iCurPage < 0 || iCurPage >= m_pSDKDoc->GetPageCount()) { 575 iCurPage < 0 || iCurPage >= m_pSDKDoc->GetPageCount()) {
585 return; 576 return;
586 } 577 }
587 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 578 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
588 if (!pEnv) 579 if (!pEnv)
589 return; 580 return;
590 pEnv->FFI_SetCurrentPage(this, iCurPage); 581 pEnv->FFI_SetCurrentPage(this, iCurPage);
591 } 582 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( 646 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile(
656 bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, 647 bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
657 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb"); 648 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb");
658 bs.ReleaseBuffer(len * sizeof(unsigned short)); 649 bs.ReleaseBuffer(len * sizeof(unsigned short));
659 650
660 if (pFileHandler == NULL) 651 if (pFileHandler == NULL)
661 return; 652 return;
662 653
663 CFPDF_FileStream fileWrite(pFileHandler); 654 CFPDF_FileStream fileWrite(pFileHandler);
664 655
665 CXFA_FFDocHandler* pXFADocHander = m_pApp->GetXFAApp()->GetDocHandler();
666 CFX_ByteString content; 656 CFX_ByteString content;
667 if (fileType == FXFA_SAVEAS_XML) { 657 if (fileType == FXFA_SAVEAS_XML) {
668 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; 658 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
669 fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(), 659 fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(),
670 content.GetLength()); 660 content.GetLength());
671 CFX_WideStringC data(L"data"); 661 CFX_WideStringC data(L"data");
672 if (pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), data, &fileWrite)) { 662 if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) {
673 // Ignoring error. 663 // Ignoring error.
674 } 664 }
675 } else if (fileType == FXFA_SAVEAS_XDP) { 665 } else if (fileType == FXFA_SAVEAS_XDP) {
676 if (m_pPDFDoc == NULL) 666 if (m_pPDFDoc == NULL)
677 return; 667 return;
678 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); 668 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
679 if (pRoot == NULL) 669 if (pRoot == NULL)
680 return; 670 return;
681 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); 671 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
682 if (NULL == pAcroForm) 672 if (NULL == pAcroForm)
(...skipping 12 matching lines...) Expand all
695 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); 685 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1);
696 if (!pPrePDFObj->IsString()) 686 if (!pPrePDFObj->IsString())
697 continue; 687 continue;
698 if (!pPDFObj->IsReference()) 688 if (!pPDFObj->IsReference())
699 continue; 689 continue;
700 CPDF_Object* pDirectObj = pPDFObj->GetDirect(); 690 CPDF_Object* pDirectObj = pPDFObj->GetDirect();
701 if (!pDirectObj->IsStream()) 691 if (!pDirectObj->IsStream())
702 continue; 692 continue;
703 if (pPrePDFObj->GetString() == "form") { 693 if (pPrePDFObj->GetString() == "form") {
704 CFX_WideStringC form(L"form"); 694 CFX_WideStringC form(L"form");
705 pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), form, &fileWrite); 695 m_pXFADocView->GetDoc()->SavePackage(form, &fileWrite);
706 } else if (pPrePDFObj->GetString() == "datasets") { 696 } else if (pPrePDFObj->GetString() == "datasets") {
707 CFX_WideStringC datasets(L"datasets"); 697 CFX_WideStringC datasets(L"datasets");
708 pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), datasets, 698 m_pXFADocView->GetDoc()->SavePackage(datasets, &fileWrite);
709 &fileWrite);
710 } else { 699 } else {
711 if (i == size - 1) { 700 if (i == size - 1) {
712 CFX_WideString wPath = CFX_WideString::FromUTF16LE( 701 CFX_WideString wPath = CFX_WideString::FromUTF16LE(
713 (unsigned short*)(const FX_CHAR*)bs, 702 (unsigned short*)(const FX_CHAR*)bs,
714 bs.GetLength() / sizeof(unsigned short)); 703 bs.GetLength() / sizeof(unsigned short));
715 CFX_ByteString bPath = wPath.UTF8Encode(); 704 CFX_ByteString bPath = wPath.UTF8Encode();
716 CFX_ByteString szFormat = 705 CFX_ByteString szFormat =
717 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; 706 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
718 content.Format(szFormat, (char*)(const FX_CHAR*)bPath); 707 content.Format(szFormat, (char*)(const FX_CHAR*)bPath);
719 fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(), 708 fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(),
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 bs.ReleaseBuffer(len * sizeof(unsigned short)); 935 bs.ReleaseBuffer(len * sizeof(unsigned short));
947 936
948 if (pFileHandler == NULL) 937 if (pFileHandler == NULL)
949 return NULL; 938 return NULL;
950 return new CFPDF_FileStream(pFileHandler); 939 return new CFPDF_FileStream(pFileHandler);
951 } 940 }
952 FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, 941 FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
953 int fileType, 942 int fileType,
954 FPDF_DWORD encodeType, 943 FPDF_DWORD encodeType,
955 FPDF_DWORD flag) { 944 FPDF_DWORD flag) {
956 if (NULL == m_pXFADocView) 945 if (!m_pXFADocView)
957 return FALSE; 946 return FALSE;
958 CXFA_FFDocHandler* pDocHandler = m_pApp->GetXFAApp()->GetDocHandler(); 947
959 CFX_ByteString content; 948 CFX_ByteString content;
960
961 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 949 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
962 if (pEnv == NULL) 950 if (!pEnv)
963 return FALSE; 951 return FALSE;
964 952
965 CFPDF_FileStream fileStream(pFileHandler); 953 CFPDF_FileStream fileStream(pFileHandler);
966 954
967 if (fileType == FXFA_SAVEAS_XML) { 955 if (fileType == FXFA_SAVEAS_XML) {
968 CFX_WideString ws; 956 CFX_WideString ws;
969 ws.FromLocal("data"); 957 ws.FromLocal("data");
970 CFX_ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; 958 CFX_ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
971 fileStream.WriteBlock((const FX_CHAR*)content, 0, content.GetLength()); 959 fileStream.WriteBlock((const FX_CHAR*)content, 0, content.GetLength());
972 pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream); 960 m_pXFADoc->SavePackage(ws, &fileStream);
973 } else if (fileType == FXFA_SAVEAS_XDP) { 961 } else if (fileType == FXFA_SAVEAS_XDP) {
974 if (flag == 0) 962 if (flag == 0)
975 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | 963 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
976 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; 964 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
977 if (m_pPDFDoc == NULL) { 965 if (m_pPDFDoc == NULL) {
978 fileStream.Flush(); 966 fileStream.Flush();
979 return FALSE; 967 return FALSE;
980 } 968 }
981 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); 969 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
982 if (pRoot == NULL) { 970 if (pRoot == NULL) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 continue; 1011 continue;
1024 if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA)) 1012 if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA))
1025 continue; 1013 continue;
1026 if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF)) 1014 if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF))
1027 continue; 1015 continue;
1028 if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM)) 1016 if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM))
1029 continue; 1017 continue;
1030 if (pPrePDFObj->GetString() == "form") { 1018 if (pPrePDFObj->GetString() == "form") {
1031 CFX_WideString ws; 1019 CFX_WideString ws;
1032 ws.FromLocal("form"); 1020 ws.FromLocal("form");
1033 pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream); 1021 m_pXFADoc->SavePackage(ws, &fileStream);
1034 } else if (pPrePDFObj->GetString() == "datasets") { 1022 } else if (pPrePDFObj->GetString() == "datasets") {
1035 CFX_WideString ws; 1023 CFX_WideString ws;
1036 ws.FromLocal("datasets"); 1024 ws.FromLocal("datasets");
1037 pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream); 1025 m_pXFADoc->SavePackage(ws, &fileStream);
1038 } else { 1026 } else {
1039 // PDF,creator. 1027 // PDF,creator.
1040 } 1028 }
1041 } 1029 }
1042 } 1030 }
1043 return TRUE; 1031 return TRUE;
1044 } 1032 }
1045 1033
1046 void CPDFXFA_Document::_ClearChangeMark() { 1034 void CPDFXFA_Document::_ClearChangeMark() {
1047 if (m_pSDKDoc) 1035 if (m_pSDKDoc)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 } 1272 }
1285 1273
1286 return _GetHValueByName(szPropName, hValue, 1274 return _GetHValueByName(szPropName, hValue,
1287 m_pSDKDoc->GetEnv()->GetJSRuntime()); 1275 m_pSDKDoc->GetEnv()->GetJSRuntime());
1288 } 1276 }
1289 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, 1277 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name,
1290 FXJSE_HVALUE hValue, 1278 FXJSE_HVALUE hValue,
1291 IJS_Runtime* runTime) { 1279 IJS_Runtime* runTime) {
1292 return runTime->GetHValueByName(utf8Name, hValue); 1280 return runTime->GetHValueByName(utf8Name, hValue);
1293 } 1281 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfsave.cpp ('k') | fpdfsdk/fsdk_annothandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698