dc15ec42d82842a3916be10a90e39173d95bfd66
[pdfium.git] / fpdfsdk / include / fpdfxfa / fpdfxfa_doc.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef FPDFXFA_DOC_H_\r
8 #define FPDFXFA_DOC_H_\r
9 \r
10 class CPDFXFA_App;\r
11 class CPDFXFA_Document;\r
12 class CPDFXFA_Page;\r
13 class CPDFSDK_Document;\r
14 class CPDFDoc_Environment;\r
15 class IFXJS_Runtime;\r
16 class IFXJS_Context;\r
17 class IXFA_DocHandler;\r
18 \r
19 class CPDFXFA_Document : public IXFA_DocProvider\r
20 {\r
21 public:\r
22         CPDFXFA_Document(CPDF_Document* pPDFDoc, CPDFXFA_App* pProvider);\r
23         ~CPDFXFA_Document();\r
24 \r
25         FX_BOOL                         LoadXFADoc();\r
26         CPDFXFA_App*            GetApp() {return m_pApp;}\r
27         CPDF_Document*          GetPDFDoc() { return m_pPDFDoc; }\r
28         IXFA_Doc*                       GetXFADoc() { return m_pXFADoc; }\r
29         IXFA_DocView*       GetXFADocView() { return m_pXFADocView; }\r
30 \r
31         int                                     GetPageCount();\r
32         CPDFXFA_Page*           GetPage(int page_index);\r
33         CPDFXFA_Page*           GetPage(IXFA_PageView* pPage);\r
34         void                            RemovePage(CPDFXFA_Page* page);\r
35         int                                     GetDocType(){ return m_iDocType; }\r
36 \r
37         CPDFSDK_Document*       GetSDKDocument(CPDFDoc_Environment* pFormFillEnv);\r
38         void                            ReleaseSDKDoc();\r
39 \r
40         void                            FXRect2PDFRect(const CFX_RectF& fxRectF, CPDF_Rect& pdfRect);\r
41 \r
42 public:\r
43         virtual void            SetChangeMark(IXFA_Doc* hDoc);\r
44         virtual FX_BOOL         GetChangeMark(IXFA_Doc* hDoc);\r
45         //used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros.\r
46         virtual void            InvalidateRect(IXFA_PageView* pPageView, const CFX_RectF& rt, FX_DWORD dwFlags = 0);\r
47         //used in static xfa, dwFlags refer to XFA_INVALIDATE_XXX macros.\r
48         virtual void            InvalidateRect(XFA_HWIDGET hWidget, FX_DWORD dwFlags = 0);\r
49         //show or hide caret\r
50         virtual void            DisplayCaret(XFA_HWIDGET hWidget, FX_BOOL bVisible, const CFX_RectF* pRtAnchor);\r
51         //dwPos: (0:bottom 1:top)\r
52         virtual FX_BOOL         GetPopupPos(XFA_HWIDGET hWidget, FX_FLOAT fMinPopup, FX_FLOAT fMaxPopup, \r
53                                                         const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);\r
54         virtual FX_BOOL         PopupMenu(XFA_HWIDGET hWidget, CFX_PointF ptPopup, const CFX_RectF* pRectExclude = NULL);\r
55 \r
56         //dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing\r
57         virtual void            PageViewEvent(IXFA_PageView* pPageView, FX_DWORD dwFlags);\r
58         //dwEvent refer to XFA_WIDGETEVENT_XXX\r
59         virtual void            WidgetEvent(XFA_HWIDGET hWidget, CXFA_WidgetAcc* pWidgetData, FX_DWORD dwEvent, FX_LPVOID pParam = NULL, FX_LPVOID pAdditional = NULL);\r
60         \r
61         //return true if render it.\r
62         virtual FX_BOOL         RenderCustomWidget(XFA_HWIDGET hWidget, CFX_Graphics* pGS, CFX_Matrix* pMatrix, const CFX_RectF& rtUI){return FALSE;}\r
63 \r
64         //host method\r
65         virtual FX_INT32        CountPages(IXFA_Doc* hDoc);\r
66         virtual FX_INT32        GetCurrentPage(IXFA_Doc* hDoc);\r
67         virtual void            SetCurrentPage(IXFA_Doc* hDoc, FX_INT32 iCurPage);\r
68         virtual FX_BOOL         IsCalculationsEnabled(IXFA_Doc* hDoc);\r
69         virtual void            SetCalculationsEnabled(IXFA_Doc* hDoc, FX_BOOL bEnabled);\r
70         virtual void            GetTitle(IXFA_Doc* hDoc, CFX_WideString &wsTitle);\r
71         virtual void            SetTitle(IXFA_Doc* hDoc, FX_WSTR wsTitle);\r
72         virtual void            ExportData(IXFA_Doc* hDoc, FX_WSTR wsFilePath, FX_BOOL bXDP = TRUE);\r
73         virtual void            ImportData(IXFA_Doc* hDoc, FX_WSTR wsFilePath);\r
74         virtual void            GotoURL(IXFA_Doc* hDoc, FX_WSTR bsURL, FX_BOOL bAppend = TRUE);\r
75         virtual FX_BOOL         IsValidationsEnabled(IXFA_Doc* hDoc);\r
76         virtual void            SetValidationsEnabled(IXFA_Doc* hDoc, FX_BOOL bEnabled);\r
77         virtual void            SetFocusWidget(IXFA_Doc* hDoc, XFA_HWIDGET hWidget);\r
78         virtual void            Print(IXFA_Doc* hDoc, FX_INT32 nStartPage, FX_INT32 nEndPage, FX_DWORD dwOptions);\r
79 \r
80         //LayoutPseudo method\r
81         virtual FX_INT32                        AbsPageCountInBatch(IXFA_Doc* hDoc){return 0;}\r
82         virtual FX_INT32                        AbsPageInBatch(IXFA_Doc* hDoc, XFA_HWIDGET hWidget){return 0;}\r
83         virtual FX_INT32                        SheetCountInBatch(IXFA_Doc* hDoc){return 0;}\r
84         virtual FX_INT32                        SheetInBatch(IXFA_Doc* hDoc, XFA_HWIDGET hWidget){return 0;}\r
85 \r
86         //SignaturePseudoModel method\r
87         //TODO:\r
88         virtual FX_INT32                        Verify(IXFA_Doc* hDoc, CXFA_Node* pSigNode, FX_BOOL bUsed = TRUE/*, SecurityHandler* pHandler, SignatureInfo &info*/) {return 0;}\r
89         virtual FX_BOOL                         Sign(IXFA_Doc* hDoc, CXFA_NodeList* pNodeList, FX_WSTR wsExpression, FX_WSTR wsXMLIdent, FX_WSTR wsValue = FX_WSTRC(L"open"), FX_BOOL bUsed = TRUE/*, SecurityHandler* pHandler = NULL, SignatureInfo &info*/) {return 0;}\r
90         virtual CXFA_NodeList*          Enumerate(IXFA_Doc* hDoc) {return 0;}\r
91         virtual FX_BOOL                         Clear(IXFA_Doc* hDoc, CXFA_Node* pSigNode, FX_BOOL bCleared = TRUE) {return 0;}\r
92 \r
93         //Get document path\r
94         virtual void            GetURL(IXFA_Doc* hDoc, CFX_WideString &wsDocURL);\r
95         virtual FX_ARGB         GetHighlightColor(IXFA_Doc* hDoc);\r
96         virtual void            AddDoRecord(XFA_HWIDGET hWidget);\r
97         /** \r
98          *Submit data to email, http, ftp.      \r
99          * @param[in] hDoc The document handler.\r
100          * @param[in] eFormat Determines the format in which the data will be submitted. XFA_ATTRIBUTEENUM_Xdp, XFA_ATTRIBUTEENUM_Xml...\r
101          * @param[in] wsTarget The URL to which the data will be submitted.\r
102          * @param[in] eEncoding The encoding of text content.\r
103          * @param[in] pXDPContent Controls what subset of the data is submitted, used only when the format property is xdp.\r
104          * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted content or not.\r
105          */\r
106         virtual FX_BOOL         SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit);\r
107 \r
108         virtual FX_BOOL         CheckWord(IXFA_Doc* hDoc, FX_BSTR sWord){return FALSE;}\r
109         virtual FX_BOOL         GetSuggestWords(IXFA_Doc* hDoc, FX_BSTR sWord, CFX_ByteStringArray& sSuggest){return FALSE;}\r
110 \r
111         //Get PDF javascript object, set the object to hValue.\r
112         virtual FX_BOOL         GetPDFScriptObject(IXFA_Doc* hDoc, FX_BSTR utf8Name, FXJSE_HVALUE hValue);\r
113 \r
114         virtual FX_BOOL         GetGlobalProperty(IXFA_Doc* hDoc, FX_BSTR szPropName, FXJSE_HVALUE hValue);\r
115         virtual FX_BOOL         SetGlobalProperty(IXFA_Doc* hDoc, FX_BSTR szPropName, FXJSE_HVALUE hValue);\r
116         virtual CPDF_Document*  OpenPDF(IXFA_Doc* hDoc, IFX_FileRead* pFile, FX_BOOL bTakeOverFile){return NULL;}\r
117 \r
118         virtual IFX_FileRead*   OpenLinkedFile(IXFA_Doc* hDoc, const CFX_WideString& wsLink);\r
119 \r
120         FX_BOOL         _GetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue, IFXJS_Runtime* runTime);\r
121         FX_BOOL         _OnBeforeNotifySumbit();\r
122         void            _OnAfterNotifySumbit();\r
123         FX_BOOL         _NotifySubmit(FX_BOOL bPrevOrPost);\r
124         FX_BOOL         _SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit);\r
125         FX_BOOL         _MailToInfo(CFX_WideString& csURL, CFX_WideString& csToAddress, CFX_WideString& csCCAddress, CFX_WideString& csBCCAddress, CFX_WideString& csSubject, CFX_WideString& csMsg);\r
126         FX_BOOL         _ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler, int fileType, FPDF_DWORD encodeType, FPDF_DWORD flag = 0x01111111);\r
127         void            _ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag);\r
128         void            _ClearChangeMark();\r
129 \r
130 private:\r
131         void            CloseXFADoc(IXFA_DocHandler* pDoc) {\r
132                                         if (pDoc) {\r
133                                                 pDoc->CloseDoc(m_pXFADoc);\r
134                                                 pDoc->ReleaseDoc(m_pXFADoc);\r
135                                                 m_pXFADoc = NULL;\r
136                                                 m_pXFADocView = NULL;\r
137                                         }\r
138                                 }\r
139 \r
140         CPDF_Document* m_pPDFDoc;\r
141         IXFA_Doc*  m_pXFADoc;\r
142         IXFA_DocView* m_pXFADocView;\r
143         CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList;\r
144 \r
145         CPDFSDK_Document* m_pSDKDoc;\r
146         CPDFXFA_App* m_pApp;\r
147 \r
148         CFX_MapByteStringToPtr  m_XfaGlobalProperty;\r
149 \r
150         CFX_MapByteStringToPtr  m_ValueMap;\r
151 \r
152         IFXJS_Context*                  m_pJSContext;\r
153 \r
154         int                     m_iDocType;\r
155 };\r
156 \r
157 #endif  // FPDFXFA_DOC_H_\r