• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_
8 #define FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_
9 
10 #include "core/fxcrt/retain_ptr.h"
11 #include "core/fxcrt/unowned_ptr.h"
12 #include "public/fpdfview.h"
13 #include "xfa/fxfa/fxfa.h"
14 
15 class CPDFXFA_Context;
16 class IJS_EventContext;
17 
18 class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment {
19  public:
20   explicit CPDFXFA_DocEnvironment(CPDFXFA_Context*);
21   ~CPDFXFA_DocEnvironment() override;
22 
23   // IXFA_DocEnvironment
24   void SetChangeMark(CXFA_FFDoc* hDoc) override;
25   // Used in dynamic xfa.
26   void InvalidateRect(CXFA_FFPageView* pPageView, const CFX_RectF& rt) override;
27   // Show or hide caret.
28   void DisplayCaret(CXFA_FFWidget* hWidget,
29                     bool bVisible,
30                     const CFX_RectF* pRtAnchor) override;
31   // dwPos: (0:bottom 1:top)
32   bool GetPopupPos(CXFA_FFWidget* hWidget,
33                    float fMinPopup,
34                    float fMaxPopup,
35                    const CFX_RectF& rtAnchor,
36                    CFX_RectF& rtPopup) override;
37   bool PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup) override;
38 
39   // dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing
40   void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) override;
41   void WidgetPostAdd(CXFA_FFWidget* hWidget,
42                      CXFA_WidgetAcc* pWidgetAcc) override;
43   void WidgetPreRemove(CXFA_FFWidget* hWidget,
44                        CXFA_WidgetAcc* pWidgetAcc) override;
45 
46   // Host method
47   int32_t CountPages(CXFA_FFDoc* hDoc) override;
48   int32_t GetCurrentPage(CXFA_FFDoc* hDoc) override;
49   void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) override;
50   bool IsCalculationsEnabled(CXFA_FFDoc* hDoc) override;
51   void SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override;
52   void GetTitle(CXFA_FFDoc* hDoc, WideString& wsTitle) override;
53   void SetTitle(CXFA_FFDoc* hDoc, const WideString& wsTitle) override;
54   void ExportData(CXFA_FFDoc* hDoc,
55                   const WideString& wsFilePath,
56                   bool bXDP) override;
57   void GotoURL(CXFA_FFDoc* hDoc, const WideString& bsURL) override;
58   bool IsValidationsEnabled(CXFA_FFDoc* hDoc) override;
59   void SetValidationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override;
60   void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override;
61   void Print(CXFA_FFDoc* hDoc,
62              int32_t nStartPage,
63              int32_t nEndPage,
64              uint32_t dwOptions) override;
65   FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override;
66 
67   bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) override;
68 
69   bool GetGlobalProperty(CXFA_FFDoc* hDoc,
70                          const ByteStringView& szPropName,
71                          CFXJSE_Value* pValue) override;
72   bool SetGlobalProperty(CXFA_FFDoc* hDoc,
73                          const ByteStringView& szPropName,
74                          CFXJSE_Value* pValue) override;
75 
76   RetainPtr<IFX_SeekableReadStream> OpenLinkedFile(
77       CXFA_FFDoc* hDoc,
78       const WideString& wsLink) override;
79 
80  private:
81   bool OnBeforeNotifySubmit();
82   void OnAfterNotifySubmit();
83   bool NotifySubmit(bool bPrevOrPost);
84   bool SubmitInternal(CXFA_FFDoc* hDoc, CXFA_Submit* submit);
85   bool MailToInfo(WideString& csURL,
86                   WideString& csToAddress,
87                   WideString& csCCAddress,
88                   WideString& csBCCAddress,
89                   WideString& csSubject,
90                   WideString& csMsg);
91   bool ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler,
92                         int fileType,
93                         FPDF_DWORD encodeType,
94                         FPDF_DWORD flag);
95   void ToXFAContentFlags(WideString csSrcContent, FPDF_DWORD& flag);
96 
97   UnownedPtr<CPDFXFA_Context> const m_pContext;
98 };
99 
100 #endif  // FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_
101