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

Side by Side Diff: fpdfsdk/include/fsdk_mgr.h

Issue 1473503002: Introduce "underlying types" to abstract XFA differences. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase past Jun's CL. Created 5 years 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
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 #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_ 7 #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_
8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_ 8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_
9 9
10 #include <map> 10 #include <map>
(...skipping 17 matching lines...) Expand all
28 class CPDFSDK_ActionHandler; 28 class CPDFSDK_ActionHandler;
29 class CPDFSDK_Annot; 29 class CPDFSDK_Annot;
30 class CPDFSDK_Document; 30 class CPDFSDK_Document;
31 class CPDFSDK_InterForm; 31 class CPDFSDK_InterForm;
32 class CPDFSDK_PageView; 32 class CPDFSDK_PageView;
33 class CPDFSDK_Widget; 33 class CPDFSDK_Widget;
34 class IFX_SystemHandler; 34 class IFX_SystemHandler;
35 35
36 class CPDFDoc_Environment final { 36 class CPDFDoc_Environment final {
37 public: 37 public:
38 CPDFDoc_Environment(CPDFXFA_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo); 38 CPDFDoc_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo);
39 ~CPDFDoc_Environment(); 39 ~CPDFDoc_Environment();
40 40
41 void Release() { 41 void Release() {
42 if (m_pInfo && m_pInfo->Release) 42 if (m_pInfo && m_pInfo->Release)
43 m_pInfo->Release(m_pInfo); 43 m_pInfo->Release(m_pInfo);
44 delete this; 44 delete this;
45 } 45 }
46 46
47 void FFI_Invalidate(FPDF_PAGE page, 47 void FFI_Invalidate(FPDF_PAGE page,
48 double left, 48 double left,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 bsRet.GetLength() / sizeof(unsigned short)); 442 bsRet.GetLength() / sizeof(unsigned short));
443 delete[] pbuff; 443 delete[] pbuff;
444 return wsRet; 444 return wsRet;
445 } 445 }
446 return L""; 446 return L"";
447 } 447 }
448 448
449 FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } 449 FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; }
450 void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; } 450 void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; }
451 CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; } 451 CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; }
452 CPDFXFA_Document* GetPDFXFADocument() const { return m_pXFADoc; } 452 UnderlyingDocumentType* GetUnderlyingDocument() const {
453 return m_pUnderlyingDoc;
454 }
453 CFX_ByteString GetAppName() const { return ""; } 455 CFX_ByteString GetAppName() const { return ""; }
454 IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); } 456 IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); }
455 FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } 457 FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; }
456 458
457 CFFL_IFormFiller* GetIFormFiller(); // Creates if not present. 459 CFFL_IFormFiller* GetIFormFiller(); // Creates if not present.
458 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. 460 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present.
459 IJS_Runtime* GetJSRuntime(); // Creates if not present. 461 IJS_Runtime* GetJSRuntime(); // Creates if not present.
460 CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. 462 CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present.
461 463
462 private: 464 private:
463 nonstd::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; 465 nonstd::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr;
464 nonstd::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; 466 nonstd::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler;
465 nonstd::unique_ptr<IJS_Runtime> m_pJSRuntime; 467 nonstd::unique_ptr<IJS_Runtime> m_pJSRuntime;
466 FPDF_FORMFILLINFO* const m_pInfo; 468 FPDF_FORMFILLINFO* const m_pInfo;
467 CPDFSDK_Document* m_pSDKDoc; 469 CPDFSDK_Document* m_pSDKDoc;
468 CPDFXFA_Document* const m_pXFADoc; 470 UnderlyingDocumentType* const m_pUnderlyingDoc;
469 nonstd::unique_ptr<CFFL_IFormFiller> m_pIFormFiller; 471 nonstd::unique_ptr<CFFL_IFormFiller> m_pIFormFiller;
470 nonstd::unique_ptr<IFX_SystemHandler> m_pSysHandler; 472 nonstd::unique_ptr<IFX_SystemHandler> m_pSysHandler;
471 }; 473 };
472 474
473 class CPDFSDK_Document { 475 class CPDFSDK_Document {
474 public: 476 public:
475 CPDFSDK_Document(CPDFXFA_Document* pDoc, CPDFDoc_Environment* pEnv); 477 CPDFSDK_Document(UnderlyingDocumentType* pDoc, CPDFDoc_Environment* pEnv);
476 ~CPDFSDK_Document(); 478 ~CPDFSDK_Document();
477 479
478 CPDFSDK_InterForm* GetInterForm(); 480 CPDFSDK_InterForm* GetInterForm();
479 CPDFXFA_Document* GetDocument() const { return m_pDoc; } 481
482 UnderlyingDocumentType* GetUnderlyingDocument() const {
483 return GetXFADocument();
484 }
480 CPDF_Document* GetPDFDocument() const { 485 CPDF_Document* GetPDFDocument() const {
481 return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr; 486 return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr;
482 } 487 }
488 CPDFXFA_Document* GetXFADocument() const { return m_pDoc; }
483 489
484 int GetPageViewCount() const { return m_pageMap.size(); } 490 int GetPageViewCount() const { return m_pageMap.size(); }
485 CPDFSDK_PageView* GetPageView(CPDFXFA_Page* pPDFXFAPage, 491 CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPDFXFAPage,
486 FX_BOOL ReNew = TRUE); 492 FX_BOOL ReNew = TRUE);
487 CPDFSDK_PageView* GetPageView(int nIndex); 493 CPDFSDK_PageView* GetPageView(int nIndex);
488 CPDFSDK_PageView* GetCurrentView(); 494 CPDFSDK_PageView* GetCurrentView();
489 void ReMovePageView(CPDFXFA_Page* pPDFPage); 495 void RemovePageView(UnderlyingPageType* pPDFPage);
490 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); 496 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot);
491 497
492 CPDFSDK_Annot* GetFocusAnnot(); 498 CPDFSDK_Annot* GetFocusAnnot();
493 499
494 IJS_Runtime* GetJsRuntime(); 500 IJS_Runtime* GetJsRuntime();
495 501
496 FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); 502 FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);
497 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); 503 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0);
498 504
499 FX_BOOL ExtractPages(const CFX_WordArray& arrExtraPages, 505 FX_BOOL ExtractPages(const CFX_WordArray& arrExtraPages,
500 CPDF_Document* pDstDoc); 506 CPDF_Document* pDstDoc);
501 FX_BOOL InsertPages(int nInsertAt, 507 FX_BOOL InsertPages(int nInsertAt,
502 const CPDF_Document* pSrcDoc, 508 const CPDF_Document* pSrcDoc,
503 const CFX_WordArray& arrSrcPages); 509 const CFX_WordArray& arrSrcPages);
504 FX_BOOL DeletePages(int nStart, int nCount);
505 FX_BOOL ReplacePages(int nPage, 510 FX_BOOL ReplacePages(int nPage,
506 const CPDF_Document* pSrcDoc, 511 const CPDF_Document* pSrcDoc,
507 const CFX_WordArray& arrSrcPages); 512 const CFX_WordArray& arrSrcPages);
508 513
509 void OnCloseDocument(); 514 void OnCloseDocument();
510 515
511 int GetPageCount() { return m_pDoc->GetPageCount(); } 516 int GetPageCount() { return m_pDoc->GetPageCount(); }
512 FX_BOOL GetPermissions(int nFlag); 517 FX_BOOL GetPermissions(int nFlag);
513 FX_BOOL GetChangeMark() { return m_bChangeMask; } 518 FX_BOOL GetChangeMark() { return m_bChangeMask; }
514 void SetChangeMark() { m_bChangeMask = TRUE; } 519 void SetChangeMark() { m_bChangeMask = TRUE; }
515 void ClearChangeMark() { m_bChangeMask = FALSE; } 520 void ClearChangeMark() { m_bChangeMask = FALSE; }
516 CFX_WideString GetPath(); 521 CFX_WideString GetPath();
517 CPDFXFA_Page* GetPage(int nIndex); 522 CPDFXFA_Page* GetPage(int nIndex);
518 CPDFDoc_Environment* GetEnv() { return m_pEnv; } 523 CPDFDoc_Environment* GetEnv() { return m_pEnv; }
519 void ProcJavascriptFun(); 524 void ProcJavascriptFun();
520 FX_BOOL ProcOpenAction(); 525 FX_BOOL ProcOpenAction();
521 CPDF_OCContext* GetOCContext(); 526 CPDF_OCContext* GetOCContext();
522 527
523 private: 528 private:
524 std::map<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap; 529 std::map<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap;
525 CPDFXFA_Document* m_pDoc; 530 UnderlyingDocumentType* m_pDoc;
526 nonstd::unique_ptr<CPDFSDK_InterForm> m_pInterForm; 531 nonstd::unique_ptr<CPDFSDK_InterForm> m_pInterForm;
527 CPDFSDK_Annot* m_pFocusAnnot; 532 CPDFSDK_Annot* m_pFocusAnnot;
528 CPDFDoc_Environment* m_pEnv; 533 CPDFDoc_Environment* m_pEnv;
529 nonstd::unique_ptr<CPDF_OCContext> m_pOccontent; 534 nonstd::unique_ptr<CPDF_OCContext> m_pOccontent;
530 FX_BOOL m_bChangeMask; 535 FX_BOOL m_bChangeMask;
531 FX_BOOL m_bBeingDestroyed; 536 FX_BOOL m_bBeingDestroyed;
532 }; 537 };
533 class CPDFSDK_PageView final { 538 class CPDFSDK_PageView final {
534 public: 539 public:
535 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, CPDFXFA_Page* page); 540 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, CPDFXFA_Page* page);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 682 }
678 683
679 if (nStartPos < m) 684 if (nStartPos < m)
680 QuickSort(nStartPos, m, bAscend, pCompare); 685 QuickSort(nStartPos, m, bAscend, pCompare);
681 if (nStopPos > m) 686 if (nStopPos > m)
682 QuickSort(m, nStopPos, bAscend, pCompare); 687 QuickSort(m, nStopPos, bAscend, pCompare);
683 } 688 }
684 }; 689 };
685 690
686 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ 691 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698