• 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/cfx_retain_ptr.h"
11 #include "public/fpdfview.h"
12 #include "xfa/fxfa/fxfa.h"
13 
14 class CPDFXFA_Context;
15 class IJS_EventContext;
16 
17 class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment {
18  public:
19   explicit CPDFXFA_DocEnvironment(CPDFXFA_Context*);
20   ~CPDFXFA_DocEnvironment() override;
21 
22   // IXFA_DocEnvironment
23   void SetChangeMark(CXFA_FFDoc* hDoc) override;
24   // used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros.
25   void InvalidateRect(CXFA_FFPageView* pPageView,
26                       const CFX_RectF& rt,
27                       uint32_t dwFlags) override;
28   // show or hide caret
29   void DisplayCaret(CXFA_FFWidget* hWidget,
30                     bool bVisible,
31                     const CFX_RectF* pRtAnchor) override;
32   // dwPos: (0:bottom 1:top)
33   bool GetPopupPos(CXFA_FFWidget* hWidget,
34                    FX_FLOAT fMinPopup,
35                    FX_FLOAT fMaxPopup,
36                    const CFX_RectF& rtAnchor,
37                    CFX_RectF& rtPopup) override;
38   bool PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup) override;
39 
40   // dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing
41   void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) override;
42   void WidgetPostAdd(CXFA_FFWidget* hWidget,
43                      CXFA_WidgetAcc* pWidgetData) override;
44   void WidgetPreRemove(CXFA_FFWidget* hWidget,
45                        CXFA_WidgetAcc* pWidgetData) override;
46 
47   // Host method
48   int32_t CountPages(CXFA_FFDoc* hDoc) override;
49   int32_t GetCurrentPage(CXFA_FFDoc* hDoc) override;
50   void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) override;
51   bool IsCalculationsEnabled(CXFA_FFDoc* hDoc) override;
52   void SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override;
53   void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) override;
54   void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) override;
55   void ExportData(CXFA_FFDoc* hDoc,
56                   const CFX_WideString& wsFilePath,
57                   bool bXDP) override;
58   void GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL) override;
59   bool IsValidationsEnabled(CXFA_FFDoc* hDoc) override;
60   void SetValidationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override;
61   void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override;
62   void Print(CXFA_FFDoc* hDoc,
63              int32_t nStartPage,
64              int32_t nEndPage,
65              uint32_t dwOptions) override;
66   FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override;
67 
68   /**
69    *Submit data to email, http, ftp.
70    * @param[in] hDoc The document handler.
71    * @param[in] eFormat Determines the format in which the data will be
72    *submitted. XFA_ATTRIBUTEENUM_Xdp, XFA_ATTRIBUTEENUM_Xml...
73    * @param[in] wsTarget The URL to which the data will be submitted.
74    * @param[in] eEncoding The encoding of text content.
75    * @param[in] pXDPContent Controls what subset of the data is submitted, used
76    *only when the format property is xdp.
77    * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted
78    *content or not.
79    */
80   bool SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) override;
81 
82   bool GetGlobalProperty(CXFA_FFDoc* hDoc,
83                          const CFX_ByteStringC& szPropName,
84                          CFXJSE_Value* pValue) override;
85   bool SetGlobalProperty(CXFA_FFDoc* hDoc,
86                          const CFX_ByteStringC& szPropName,
87                          CFXJSE_Value* pValue) override;
88 
89   CFX_RetainPtr<IFX_SeekableReadStream> OpenLinkedFile(
90       CXFA_FFDoc* hDoc,
91       const CFX_WideString& wsLink) override;
92 
93  private:
94   bool OnBeforeNotifySubmit();
95   void OnAfterNotifySubmit();
96   bool NotifySubmit(bool bPrevOrPost);
97   bool SubmitDataInternal(CXFA_FFDoc* hDoc, CXFA_Submit submit);
98   bool MailToInfo(CFX_WideString& csURL,
99                   CFX_WideString& csToAddress,
100                   CFX_WideString& csCCAddress,
101                   CFX_WideString& csBCCAddress,
102                   CFX_WideString& csSubject,
103                   CFX_WideString& csMsg);
104   bool ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler,
105                         int fileType,
106                         FPDF_DWORD encodeType,
107                         FPDF_DWORD flag);
108   void ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag);
109 
110   CPDFXFA_Context* const m_pContext;    // Not owned.
111   IJS_EventContext* m_pJSEventContext;  // Not owned.
112 };
113 
114 #endif  // FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_
115