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

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

Issue 2335243002: Split fsdk_mgr files apart. (Closed)
Patch Set: Sort headers Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2016 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_CPDFDOC_ENVIRONMENT_H_
8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_ 8 #define FPDFSDK_INCLUDE_CPDFDOC_ENVIRONMENT_H_
9 9
10 #include <map>
11 #include <memory> 10 #include <memory>
12 #include <vector>
13 11
14 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
16 #include "core/fpdfdoc/include/cpdf_occontext.h" 14 #include "core/fpdfdoc/include/cpdf_occontext.h"
17 #include "core/fxcrt/include/cfx_observable.h" 15 #include "core/fxcrt/include/cfx_observable.h"
18 #include "fpdfsdk/cfx_systemhandler.h" 16 #include "fpdfsdk/cfx_systemhandler.h"
19 #include "fpdfsdk/include/cpdfsdk_annot.h"
20 #include "fpdfsdk/include/fsdk_actionhandler.h"
21 #include "fpdfsdk/include/fsdk_common.h"
22 #include "fpdfsdk/include/fsdk_define.h" 17 #include "fpdfsdk/include/fsdk_define.h"
23 #include "public/fpdf_formfill.h" 18 #include "public/fpdf_formfill.h"
24 #include "public/fpdf_fwlevent.h" 19 #include "public/fpdf_fwlevent.h"
25 20
26 class CFFL_IFormFiller; 21 class CFFL_IFormFiller;
27 class CFX_SystemHandler; 22 class CFX_SystemHandler;
28 class CPDF_AnnotList;
29 class CPDFSDK_ActionHandler; 23 class CPDFSDK_ActionHandler;
30 class CPDFSDK_Annot;
31 class CPDFSDK_AnnotHandlerMgr; 24 class CPDFSDK_AnnotHandlerMgr;
32 class CPDFSDK_InterForm; 25 class CPDFSDK_Document;
33 class CPDFSDK_PageView;
34 class CPDFSDK_Widget;
35 class IJS_Runtime; 26 class IJS_Runtime;
36 27
37 class CPDFDoc_Environment final { 28 class CPDFDoc_Environment final {
38 public: 29 public:
39 CPDFDoc_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo); 30 CPDFDoc_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo);
40 ~CPDFDoc_Environment(); 31 ~CPDFDoc_Environment();
41 32
42 void FFI_Invalidate(FPDF_PAGE page, 33 void FFI_Invalidate(FPDF_PAGE page,
43 double left, 34 double left,
44 double top, 35 double top,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; 429 std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr;
439 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; 430 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler;
440 std::unique_ptr<IJS_Runtime> m_pJSRuntime; 431 std::unique_ptr<IJS_Runtime> m_pJSRuntime;
441 FPDF_FORMFILLINFO* const m_pInfo; 432 FPDF_FORMFILLINFO* const m_pInfo;
442 CPDFSDK_Document* m_pSDKDoc; 433 CPDFSDK_Document* m_pSDKDoc;
443 UnderlyingDocumentType* const m_pUnderlyingDoc; 434 UnderlyingDocumentType* const m_pUnderlyingDoc;
444 std::unique_ptr<CFFL_IFormFiller> m_pIFormFiller; 435 std::unique_ptr<CFFL_IFormFiller> m_pIFormFiller;
445 std::unique_ptr<CFX_SystemHandler> m_pSysHandler; 436 std::unique_ptr<CFX_SystemHandler> m_pSysHandler;
446 }; 437 };
447 438
448 class CPDFSDK_Document : public CFX_Observable<CPDFSDK_Document> { 439 #endif // FPDFSDK_INCLUDE_CPDFDOC_ENVIRONMENT_H_
449 public:
450 static CPDFSDK_Document* FromFPDFFormHandle(FPDF_FORMHANDLE hHandle);
451
452 CPDFSDK_Document(UnderlyingDocumentType* pDoc, CPDFDoc_Environment* pEnv);
453 ~CPDFSDK_Document();
454
455 CPDFSDK_InterForm* GetInterForm();
456
457 // Gets the document object for the next layer down; for master this is
458 // a CPDF_Document, but for XFA it is a CPDFXFA_Document.
459 UnderlyingDocumentType* GetUnderlyingDocument() const {
460 #ifdef PDF_ENABLE_XFA
461 return GetXFADocument();
462 #else // PDF_ENABLE_XFA
463 return GetPDFDocument();
464 #endif // PDF_ENABLE_XFA
465 }
466
467 // Gets the CPDF_Document, either directly in master, or from the
468 // CPDFXFA_Document for XFA.
469 CPDF_Document* GetPDFDocument() const {
470 #ifdef PDF_ENABLE_XFA
471 return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr;
472 #else // PDF_ENABLE_XFA
473 return m_pDoc;
474 #endif // PDF_ENABLE_XFA
475 }
476
477 #ifdef PDF_ENABLE_XFA
478 // Gets the XFA document directly (XFA-only).
479 CPDFXFA_Document* GetXFADocument() const { return m_pDoc; }
480
481 int GetPageViewCount() const { return m_pageMap.size(); }
482 #endif // PDF_ENABLE_XFA
483
484 CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, bool ReNew);
485 CPDFSDK_PageView* GetPageView(int nIndex);
486 CPDFSDK_PageView* GetCurrentView();
487 void RemovePageView(UnderlyingPageType* pPage);
488 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot);
489
490 CPDFSDK_Annot* GetFocusAnnot();
491
492 IJS_Runtime* GetJsRuntime();
493
494 FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);
495 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0);
496
497 FX_BOOL ExtractPages(const std::vector<uint16_t>& arrExtraPages,
498 CPDF_Document* pDstDoc);
499 FX_BOOL InsertPages(int nInsertAt,
500 const CPDF_Document* pSrcDoc,
501 const std::vector<uint16_t>& arrSrcPages);
502 FX_BOOL ReplacePages(int nPage,
503 const CPDF_Document* pSrcDoc,
504 const std::vector<uint16_t>& arrSrcPages);
505
506 void OnCloseDocument();
507
508 int GetPageCount() { return m_pDoc->GetPageCount(); }
509 FX_BOOL GetPermissions(int nFlag);
510 FX_BOOL GetChangeMark() { return m_bChangeMask; }
511 void SetChangeMark() { m_bChangeMask = TRUE; }
512 void ClearChangeMark() { m_bChangeMask = FALSE; }
513 CFX_WideString GetPath();
514 UnderlyingPageType* GetPage(int nIndex);
515 CPDFDoc_Environment* GetEnv() { return m_pEnv; }
516 void ProcJavascriptFun();
517 FX_BOOL ProcOpenAction();
518 CPDF_OCContext* GetOCContext();
519
520 private:
521 std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap;
522 UnderlyingDocumentType* m_pDoc;
523 std::unique_ptr<CPDFSDK_InterForm> m_pInterForm;
524 CPDFSDK_Annot* m_pFocusAnnot;
525 CPDFDoc_Environment* m_pEnv;
526 std::unique_ptr<CPDF_OCContext> m_pOccontent;
527 FX_BOOL m_bChangeMask;
528 FX_BOOL m_bBeingDestroyed;
529 };
530
531 class CPDFSDK_PageView final : public CPDF_Page::View {
532 public:
533 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page);
534 ~CPDFSDK_PageView();
535
536 #ifdef PDF_ENABLE_XFA
537 void PageView_OnDraw(CFX_RenderDevice* pDevice,
538 CFX_Matrix* pUser2Device,
539 CPDF_RenderOptions* pOptions,
540 const FX_RECT& pClip);
541 #else // PDF_ENABLE_XFA
542 void PageView_OnDraw(CFX_RenderDevice* pDevice,
543 CFX_Matrix* pUser2Device,
544 CPDF_RenderOptions* pOptions);
545 #endif // PDF_ENABLE_XFA
546
547 const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
548 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
549 const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
550 CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
551 CPDFSDK_Annot* GetFocusAnnot();
552 void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot, FX_UINT nFlag = 0) {
553 m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);
554 }
555 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {
556 return m_pSDKDoc->KillFocusAnnot(nFlag);
557 }
558 void KillFocusAnnotIfNeeded();
559
560 CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict);
561 CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict);
562 CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot);
563
564 FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot);
565 size_t CountAnnots() const;
566 CPDFSDK_Annot* GetAnnot(size_t nIndex);
567 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict);
568
569 #ifdef PDF_ENABLE_XFA
570 CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot);
571 CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget);
572 CPDFXFA_Page* GetPDFXFAPage() { return m_page; }
573 #endif // PDF_ENABLE_XFA
574
575 CPDF_Page* GetPDFPage() const;
576 CPDF_Document* GetPDFDocument();
577 CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; }
578 FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, FX_UINT nFlag);
579 FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_UINT nFlag);
580 #ifdef PDF_ENABLE_XFA
581 FX_BOOL OnRButtonDown(const CFX_FloatPoint& point, FX_UINT nFlag);
582 FX_BOOL OnRButtonUp(const CFX_FloatPoint& point, FX_UINT nFlag);
583 #endif // PDF_ENABLE_XFA
584 FX_BOOL OnChar(int nChar, FX_UINT nFlag);
585 FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
586 FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
587
588 FX_BOOL OnMouseMove(const CFX_FloatPoint& point, int nFlag);
589 FX_BOOL OnMouseWheel(double deltaX,
590 double deltaY,
591 const CFX_FloatPoint& point,
592 int nFlag);
593 bool IsValidAnnot(const CPDF_Annot* p) const;
594 void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; }
595 void UpdateRects(const std::vector<CFX_FloatRect>& rects);
596 void UpdateView(CPDFSDK_Annot* pAnnot);
597 const std::vector<CPDFSDK_Annot*>& GetAnnotList() const {
598 return m_fxAnnotArray;
599 }
600
601 int GetPageIndex() const;
602 void LoadFXAnnots();
603 void ClearFXAnnots();
604 void SetValid(FX_BOOL bValid) { m_bValid = bValid; }
605 FX_BOOL IsValid() { return m_bValid; }
606 void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; }
607 FX_BOOL IsLocked() { return m_bLocked; }
608 #ifndef PDF_ENABLE_XFA
609 bool OwnsPage() const { return m_bOwnsPage; }
610 void TakePageOwnership() { m_bOwnsPage = true; }
611 #endif // PDF_ENABLE_XFA
612
613 private:
614 int GetPageIndexForStaticPDF() const;
615
616 CFX_Matrix m_curMatrix;
617 UnderlyingPageType* const m_page;
618 std::unique_ptr<CPDF_AnnotList> m_pAnnotList;
619 std::vector<CPDFSDK_Annot*> m_fxAnnotArray;
620 CPDFSDK_Document* const m_pSDKDoc;
621 CPDFSDK_Annot* m_CaptureWidget;
622 #ifndef PDF_ENABLE_XFA
623 bool m_bOwnsPage;
624 #endif // PDF_ENABLE_XFA
625 FX_BOOL m_bEnterWidget;
626 FX_BOOL m_bExitWidget;
627 FX_BOOL m_bOnWidget;
628 FX_BOOL m_bValid;
629 FX_BOOL m_bLocked;
630 };
631
632 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_
OLDNEW
« BUILD.gn ('K') | « fpdfsdk/fsdk_mgr.cpp ('k') | fpdfsdk/include/cpdfsdk_document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698