xref: /aosp_15_r20/external/pdfium/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2016 The PDFium Authors
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/cxfa_ffdoc.h"
14 
15 class CFX_XMLDocument;
16 class CPDFXFA_Context;
17 class IJS_Runtime;
18 
19 class CPDFXFA_DocEnvironment final : public CXFA_FFDoc::CallbackIface {
20  public:
21   explicit CPDFXFA_DocEnvironment(CPDFXFA_Context*);
22   ~CPDFXFA_DocEnvironment() override;
23 
24   // CFXA_FFDoc::CallbackIface:
25   void SetChangeMark(CXFA_FFDoc* hDoc) override;
26   void InvalidateRect(CXFA_FFPageView* pPageView, const CFX_RectF& rt) override;
27   void DisplayCaret(CXFA_FFWidget* hWidget,
28                     bool bVisible,
29                     const CFX_RectF* pRtAnchor) override;
30   bool GetPopupPos(CXFA_FFWidget* hWidget,
31                    float fMinPopup,
32                    float fMaxPopup,
33                    const CFX_RectF& rtAnchor,
34                    CFX_RectF* pPopupRect) override;
35   bool PopupMenu(CXFA_FFWidget* hWidget, const CFX_PointF& ptPopup) override;
36   void OnPageViewEvent(CXFA_FFPageView* pPageView,
37                        CXFA_FFDoc::PageViewEvent eEvent) override;
38   void WidgetPostAdd(CXFA_FFWidget* hWidget) override;
39   void WidgetPreRemove(CXFA_FFWidget* hWidget) override;
40   int32_t CountPages(const CXFA_FFDoc* hDoc) const override;
41   int32_t GetCurrentPage(const CXFA_FFDoc* hDoc) const override;
42   void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) override;
43   bool IsCalculationsEnabled(const CXFA_FFDoc* hDoc) const override;
44   void SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override;
45   WideString GetTitle(const CXFA_FFDoc* hDoc) const override;
46   void SetTitle(CXFA_FFDoc* hDoc, const WideString& wsTitle) override;
47   void ExportData(CXFA_FFDoc* hDoc,
48                   const WideString& wsFilePath,
49                   bool bXDP) override;
50   void GotoURL(CXFA_FFDoc* hDoc, const WideString& bsURL) override;
51   bool IsValidationsEnabled(const CXFA_FFDoc* hDoc) const override;
52   void SetValidationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override;
53   void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override;
54   void Print(CXFA_FFDoc* hDoc,
55              int32_t nStartPage,
56              int32_t nEndPage,
57              Mask<XFA_PrintOpt> dwOptions) override;
58   FX_ARGB GetHighlightColor(const CXFA_FFDoc* hDoc) const override;
59   IJS_Runtime* GetIJSRuntime(const CXFA_FFDoc* hDoc) const override;
60   CFX_XMLDocument* GetXMLDoc() const override;
61   RetainPtr<IFX_SeekableReadStream> OpenLinkedFile(
62       CXFA_FFDoc* hDoc,
63       const WideString& wsLink) override;
64 
65 #ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED
66   bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) override;
67 #endif  // PDF_XFA_ELEMENT_SUBMIT_ENABLED
68 
69  private:
70 #ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED
71   bool MailToInfo(WideString& csURL,
72                   WideString& csToAddress,
73                   WideString& csCCAddress,
74                   WideString& csBCCAddress,
75                   WideString& csSubject,
76                   WideString& csMsg);
77   bool ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler,
78                         int fileType,
79                         FPDF_DWORD encodeType,
80                         FPDF_DWORD flag);
81   void ToXFAContentFlags(WideString csSrcContent, FPDF_DWORD& flag);
82   bool OnBeforeNotifySubmit();
83   void OnAfterNotifySubmit();
84   bool SubmitInternal(CXFA_FFDoc* hDoc, CXFA_Submit* submit);
85 #endif  // PDF_XFA_ELEMENT_SUBMIT_ENABLED
86 
87   UnownedPtr<CPDFXFA_Context> const m_pContext;
88 };
89 
90 #endif  // FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_
91