| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ | 7 #ifndef FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ |
| 8 #define FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ | 8 #define FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ |
| 9 | 9 |
| 10 #include "xfa/fxfa/include/xfa_ffdoc.h" | 10 #include "xfa/fxfa/include/xfa_ffdoc.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class IJS_Context; | 25 class IJS_Context; |
| 26 class CXFA_FFDocHandler; | 26 class CXFA_FFDocHandler; |
| 27 | 27 |
| 28 class CPDFXFA_Document : public IXFA_DocProvider { | 28 class CPDFXFA_Document : public IXFA_DocProvider { |
| 29 public: | 29 public: |
| 30 CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, | 30 CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, |
| 31 CPDFXFA_App* pProvider); | 31 CPDFXFA_App* pProvider); |
| 32 ~CPDFXFA_Document() override; | 32 ~CPDFXFA_Document() override; |
| 33 | 33 |
| 34 FX_BOOL LoadXFADoc(); | 34 FX_BOOL LoadXFADoc(); |
| 35 CPDFXFA_App* GetApp() { return m_pApp; } | |
| 36 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } | 35 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } |
| 37 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } | 36 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } |
| 38 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } | 37 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } |
| 39 | 38 |
| 40 int GetPageCount(); | 39 int GetPageCount(); |
| 41 CPDFXFA_Page* GetPage(int page_index); | 40 CPDFXFA_Page* GetPage(int page_index); |
| 42 CPDFXFA_Page* GetPage(CXFA_FFPageView* pPage); | |
| 43 | 41 |
| 44 void DeletePage(int page_index); | 42 void DeletePage(int page_index); |
| 45 void RemovePage(CPDFXFA_Page* page); | 43 void RemovePage(CPDFXFA_Page* page); |
| 46 int GetDocType() { return m_iDocType; } | 44 int GetDocType() { return m_iDocType; } |
| 47 | 45 |
| 48 CPDFSDK_Document* GetSDKDocument(CPDFDoc_Environment* pFormFillEnv); | 46 CPDFSDK_Document* GetSDKDocument(CPDFDoc_Environment* pFormFillEnv); |
| 49 | 47 |
| 50 void FXRect2PDFRect(const CFX_RectF& fxRectF, CFX_FloatRect& pdfRect); | |
| 51 | |
| 52 // IXFA_DocProvider | 48 // IXFA_DocProvider |
| 53 void SetChangeMark(CXFA_FFDoc* hDoc) override; | 49 void SetChangeMark(CXFA_FFDoc* hDoc) override; |
| 54 // used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. | 50 // used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. |
| 55 void InvalidateRect(CXFA_FFPageView* pPageView, | 51 void InvalidateRect(CXFA_FFPageView* pPageView, |
| 56 const CFX_RectF& rt, | 52 const CFX_RectF& rt, |
| 57 uint32_t dwFlags = 0) override; | 53 uint32_t dwFlags) override; |
| 58 // show or hide caret | 54 // show or hide caret |
| 59 void DisplayCaret(CXFA_FFWidget* hWidget, | 55 void DisplayCaret(CXFA_FFWidget* hWidget, |
| 60 FX_BOOL bVisible, | 56 FX_BOOL bVisible, |
| 61 const CFX_RectF* pRtAnchor) override; | 57 const CFX_RectF* pRtAnchor) override; |
| 62 // dwPos: (0:bottom 1:top) | 58 // dwPos: (0:bottom 1:top) |
| 63 FX_BOOL GetPopupPos(CXFA_FFWidget* hWidget, | 59 FX_BOOL GetPopupPos(CXFA_FFWidget* hWidget, |
| 64 FX_FLOAT fMinPopup, | 60 FX_FLOAT fMinPopup, |
| 65 FX_FLOAT fMaxPopup, | 61 FX_FLOAT fMaxPopup, |
| 66 const CFX_RectF& rtAnchor, | 62 const CFX_RectF& rtAnchor, |
| 67 CFX_RectF& rtPopup) override; | 63 CFX_RectF& rtPopup) override; |
| 68 FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, | 64 FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup) override; |
| 69 CFX_PointF ptPopup, | |
| 70 const CFX_RectF* pRectExclude = nullptr) override; | |
| 71 | 65 |
| 72 // dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing | 66 // dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing |
| 73 void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) override; | 67 void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) override; |
| 74 void WidgetPostAdd(CXFA_FFWidget* hWidget, | 68 void WidgetPostAdd(CXFA_FFWidget* hWidget, |
| 75 CXFA_WidgetAcc* pWidgetData) override; | 69 CXFA_WidgetAcc* pWidgetData) override; |
| 76 void WidgetPreRemove(CXFA_FFWidget* hWidget, | 70 void WidgetPreRemove(CXFA_FFWidget* hWidget, |
| 77 CXFA_WidgetAcc* pWidgetData) override; | 71 CXFA_WidgetAcc* pWidgetData) override; |
| 78 | 72 |
| 79 // Host method | 73 // Host method |
| 80 int32_t CountPages(CXFA_FFDoc* hDoc) override; | 74 int32_t CountPages(CXFA_FFDoc* hDoc) override; |
| 81 int32_t GetCurrentPage(CXFA_FFDoc* hDoc) override; | 75 int32_t GetCurrentPage(CXFA_FFDoc* hDoc) override; |
| 82 void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) override; | 76 void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) override; |
| 83 FX_BOOL IsCalculationsEnabled(CXFA_FFDoc* hDoc) override; | 77 FX_BOOL IsCalculationsEnabled(CXFA_FFDoc* hDoc) override; |
| 84 void SetCalculationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) override; | 78 void SetCalculationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) override; |
| 85 void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) override; | 79 void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) override; |
| 86 void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) override; | 80 void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) override; |
| 87 void ExportData(CXFA_FFDoc* hDoc, | 81 void ExportData(CXFA_FFDoc* hDoc, |
| 88 const CFX_WideString& wsFilePath, | 82 const CFX_WideString& wsFilePath, |
| 89 FX_BOOL bXDP = TRUE) override; | 83 FX_BOOL bXDP) override; |
| 90 void GotoURL(CXFA_FFDoc* hDoc, | 84 void GotoURL(CXFA_FFDoc* hDoc, |
| 91 const CFX_WideString& bsURL, | 85 const CFX_WideString& bsURL, |
| 92 FX_BOOL bAppend = TRUE) override; | 86 FX_BOOL bAppend) override; |
| 93 FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc) override; | 87 FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc) override; |
| 94 void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) override; | 88 void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) override; |
| 95 void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; | 89 void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; |
| 96 void Print(CXFA_FFDoc* hDoc, | 90 void Print(CXFA_FFDoc* hDoc, |
| 97 int32_t nStartPage, | 91 int32_t nStartPage, |
| 98 int32_t nEndPage, | 92 int32_t nEndPage, |
| 99 uint32_t dwOptions) override; | 93 uint32_t dwOptions) override; |
| 100 // Get document path | |
| 101 void GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) override; | |
| 102 FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override; | 94 FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override; |
| 103 | 95 |
| 104 /** | 96 /** |
| 105 *Submit data to email, http, ftp. | 97 *Submit data to email, http, ftp. |
| 106 * @param[in] hDoc The document handler. | 98 * @param[in] hDoc The document handler. |
| 107 * @param[in] eFormat Determines the format in which the data will be | 99 * @param[in] eFormat Determines the format in which the data will be |
| 108 *submitted. XFA_ATTRIBUTEENUM_Xdp, XFA_ATTRIBUTEENUM_Xml... | 100 *submitted. XFA_ATTRIBUTEENUM_Xdp, XFA_ATTRIBUTEENUM_Xml... |
| 109 * @param[in] wsTarget The URL to which the data will be submitted. | 101 * @param[in] wsTarget The URL to which the data will be submitted. |
| 110 * @param[in] eEncoding The encoding of text content. | 102 * @param[in] eEncoding The encoding of text content. |
| 111 * @param[in] pXDPContent Controls what subset of the data is submitted, used | 103 * @param[in] pXDPContent Controls what subset of the data is submitted, used |
| 112 *only when the format property is xdp. | 104 *only when the format property is xdp. |
| 113 * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted | 105 * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted |
| 114 *content or not. | 106 *content or not. |
| 115 */ | 107 */ |
| 116 FX_BOOL SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) override; | 108 FX_BOOL SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) override; |
| 117 | 109 |
| 118 // Get PDF javascript object, set the object to pValue. | |
| 119 FX_BOOL GetPDFScriptObject(CXFA_FFDoc* hDoc, | |
| 120 const CFX_ByteStringC& utf8Name, | |
| 121 CFXJSE_Value* pValue) override; | |
| 122 | |
| 123 FX_BOOL GetGlobalProperty(CXFA_FFDoc* hDoc, | 110 FX_BOOL GetGlobalProperty(CXFA_FFDoc* hDoc, |
| 124 const CFX_ByteStringC& szPropName, | 111 const CFX_ByteStringC& szPropName, |
| 125 CFXJSE_Value* pValue) override; | 112 CFXJSE_Value* pValue) override; |
| 126 FX_BOOL SetGlobalProperty(CXFA_FFDoc* hDoc, | 113 FX_BOOL SetGlobalProperty(CXFA_FFDoc* hDoc, |
| 127 const CFX_ByteStringC& szPropName, | 114 const CFX_ByteStringC& szPropName, |
| 128 CFXJSE_Value* pValue) override; | 115 CFXJSE_Value* pValue) override; |
| 129 | 116 |
| 130 IFX_FileRead* OpenLinkedFile(CXFA_FFDoc* hDoc, | 117 IFX_FileRead* OpenLinkedFile(CXFA_FFDoc* hDoc, |
| 131 const CFX_WideString& wsLink) override; | 118 const CFX_WideString& wsLink) override; |
| 132 | 119 |
| 133 void ClearChangeMark(); | 120 void ClearChangeMark(); |
| 134 | 121 |
| 135 private: | 122 private: |
| 136 enum LoadStatus { | 123 enum LoadStatus { |
| 137 FXFA_LOADSTATUS_PRELOAD = 0, | 124 FXFA_LOADSTATUS_PRELOAD = 0, |
| 138 FXFA_LOADSTATUS_LOADING, | 125 FXFA_LOADSTATUS_LOADING, |
| 139 FXFA_LOADSTATUS_LOADED, | 126 FXFA_LOADSTATUS_LOADED, |
| 140 FXFA_LOADSTATUS_CLOSING, | 127 FXFA_LOADSTATUS_CLOSING, |
| 141 FXFA_LOADSTATUS_CLOSED | 128 FXFA_LOADSTATUS_CLOSED |
| 142 }; | 129 }; |
| 143 | 130 |
| 144 void CloseXFADoc(CXFA_FFDocHandler* pDoc) { | 131 void CloseXFADoc(CXFA_FFDocHandler* pDoc) { |
| 145 if (pDoc) { | 132 if (pDoc) { |
| 146 m_pXFADoc->CloseDoc(); | 133 m_pXFADoc->CloseDoc(); |
| 147 m_pXFADoc.reset(); | 134 m_pXFADoc.reset(); |
| 148 m_pXFADocView = nullptr; | 135 m_pXFADocView = nullptr; |
| 149 } | 136 } |
| 150 } | 137 } |
| 151 | 138 |
| 139 CPDFXFA_Page* GetPage(CXFA_FFPageView* pPage); |
| 152 FX_BOOL OnBeforeNotifySubmit(); | 140 FX_BOOL OnBeforeNotifySubmit(); |
| 153 void OnAfterNotifySubmit(); | 141 void OnAfterNotifySubmit(); |
| 154 FX_BOOL NotifySubmit(FX_BOOL bPrevOrPost); | 142 FX_BOOL NotifySubmit(FX_BOOL bPrevOrPost); |
| 155 FX_BOOL SubmitDataInternal(CXFA_FFDoc* hDoc, CXFA_Submit submit); | 143 FX_BOOL SubmitDataInternal(CXFA_FFDoc* hDoc, CXFA_Submit submit); |
| 156 FX_BOOL MailToInfo(CFX_WideString& csURL, | 144 FX_BOOL MailToInfo(CFX_WideString& csURL, |
| 157 CFX_WideString& csToAddress, | 145 CFX_WideString& csToAddress, |
| 158 CFX_WideString& csCCAddress, | 146 CFX_WideString& csCCAddress, |
| 159 CFX_WideString& csBCCAddress, | 147 CFX_WideString& csBCCAddress, |
| 160 CFX_WideString& csSubject, | 148 CFX_WideString& csSubject, |
| 161 CFX_WideString& csMsg); | 149 CFX_WideString& csMsg); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 174 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; | 162 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; |
| 175 CXFA_FFDocView* m_pXFADocView; // not owned. | 163 CXFA_FFDocView* m_pXFADocView; // not owned. |
| 176 CPDFXFA_App* const m_pApp; | 164 CPDFXFA_App* const m_pApp; |
| 177 IJS_Context* m_pJSContext; | 165 IJS_Context* m_pJSContext; |
| 178 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; | 166 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; |
| 179 LoadStatus m_nLoadStatus; | 167 LoadStatus m_nLoadStatus; |
| 180 int m_nPageCount; | 168 int m_nPageCount; |
| 181 }; | 169 }; |
| 182 | 170 |
| 183 #endif // FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ | 171 #endif // FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ |
| OLD | NEW |