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_Runtime; 17 18 class CPDFXFA_DocEnvironment final : 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 void InvalidateRect(CXFA_FFPageView* pPageView, const CFX_RectF& rt) override; 26 void DisplayCaret(CXFA_FFWidget* hWidget, 27 bool bVisible, 28 const CFX_RectF* pRtAnchor) override; 29 bool GetPopupPos(CXFA_FFWidget* hWidget, 30 float fMinPopup, 31 float fMaxPopup, 32 const CFX_RectF& rtAnchor, 33 CFX_RectF* pPopupRect) override; 34 bool PopupMenu(CXFA_FFWidget* hWidget, const CFX_PointF& ptPopup) override; 35 void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) override; 36 void WidgetPostAdd(CXFA_FFWidget* hWidget) override; 37 void WidgetPreRemove(CXFA_FFWidget* hWidget) override; 38 int32_t CountPages(CXFA_FFDoc* hDoc) override; 39 int32_t GetCurrentPage(CXFA_FFDoc* hDoc) override; 40 void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) override; 41 bool IsCalculationsEnabled(CXFA_FFDoc* hDoc) override; 42 void SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override; 43 void GetTitle(CXFA_FFDoc* hDoc, WideString& wsTitle) override; 44 void SetTitle(CXFA_FFDoc* hDoc, const WideString& wsTitle) override; 45 void ExportData(CXFA_FFDoc* hDoc, 46 const WideString& wsFilePath, 47 bool bXDP) override; 48 void GotoURL(CXFA_FFDoc* hDoc, const WideString& bsURL) override; 49 bool IsValidationsEnabled(CXFA_FFDoc* hDoc) override; 50 void SetValidationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) override; 51 void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; 52 void Print(CXFA_FFDoc* hDoc, 53 int32_t nStartPage, 54 int32_t nEndPage, 55 uint32_t dwOptions) override; 56 FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override; 57 IJS_Runtime* GetIJSRuntime(CXFA_FFDoc* hDoc) const override; 58 RetainPtr<IFX_SeekableReadStream> OpenLinkedFile( 59 CXFA_FFDoc* hDoc, 60 const WideString& wsLink) override; 61 62 #ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED 63 bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) override; 64 #endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED 65 66 private: 67 #ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED 68 bool MailToInfo(WideString& csURL, 69 WideString& csToAddress, 70 WideString& csCCAddress, 71 WideString& csBCCAddress, 72 WideString& csSubject, 73 WideString& csMsg); 74 bool ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler, 75 int fileType, 76 FPDF_DWORD encodeType, 77 FPDF_DWORD flag); 78 void ToXFAContentFlags(WideString csSrcContent, FPDF_DWORD& flag); 79 bool OnBeforeNotifySubmit(); 80 void OnAfterNotifySubmit(); 81 bool NotifySubmit(bool bPrevOrPost); 82 bool SubmitInternal(CXFA_FFDoc* hDoc, CXFA_Submit* submit); 83 #endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED 84 85 UnownedPtr<CPDFXFA_Context> const m_pContext; 86 }; 87 88 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_ 89