Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdfxfa_context.h
Go to the documentation of this file.
1// Copyright 2014 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_CONTEXT_H_
8#define FPDFSDK_FPDFXFA_CPDFXFA_CONTEXT_H_
9
10#include <stdint.h>
11
12#include <memory>
13#include <vector>
14
15#include "core/fpdfapi/parser/cpdf_document.h"
16#include "core/fxcrt/cfx_timer.h"
17#include "core/fxcrt/observed_ptr.h"
18#include "core/fxcrt/retain_ptr.h"
19#include "core/fxcrt/unowned_ptr.h"
20#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
21#include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
22#include "fxjs/gc/heap.h"
23#include "v8/include/cppgc/persistent.h"
24#include "xfa/fxfa/cxfa_ffapp.h"
25#include "xfa/fxfa/cxfa_ffdoc.h"
26
27class CFX_XMLDocument;
28class CJS_Runtime;
29class CPDFXFA_DocEnvironment;
30
31// Per-process initializations.
34
35class CPDFXFA_Context final : public CPDF_Document::Extension,
36 public CXFA_FFApp::CallbackIface {
37 public:
38 enum class LoadStatus : uint8_t {
39 kPreload = 0,
41 kLoaded,
43 };
44
45 explicit CPDFXFA_Context(CPDF_Document* pPDFDoc);
46 ~CPDFXFA_Context() override;
47
48 bool LoadXFADoc();
49 LoadStatus GetLoadStatus() const { return m_nLoadStatus; }
50 FormType GetFormType() const { return m_FormType; }
51 int GetOriginalPageCount() const { return m_nPageCount; }
52 void SetOriginalPageCount(int count) {
53 m_nPageCount = count;
54 m_XFAPageList.resize(count);
55 }
56
57 CPDF_Document* GetPDFDoc() const { return m_pPDFDoc; }
58 CFX_XMLDocument* GetXMLDoc() { return m_pXML.get(); }
59 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc; }
60 CXFA_FFDocView* GetXFADocView() const { return m_pXFADocView.Get(); }
61 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const {
62 return m_pFormFillEnv.Get();
63 }
64 void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv);
65 RetainPtr<CPDFXFA_Page> GetOrCreateXFAPage(int page_index);
66 RetainPtr<CPDFXFA_Page> GetXFAPage(int page_index);
67 RetainPtr<CPDFXFA_Page> GetXFAPage(CXFA_FFPageView* pPage) const;
68 void ClearChangeMark();
69
70 // CPDF_Document::Extension:
71 int GetPageCount() const override;
72 void DeletePage(int page_index) override;
73 bool ContainsExtensionForm() const override;
74 bool ContainsExtensionFullForm() const override;
75 bool ContainsExtensionForegroundForm() const override;
76
77 // CXFA_FFApp::CallbackIface:
78 WideString GetLanguage() override;
79 WideString GetPlatform() override;
80 WideString GetAppName() override;
81 WideString GetAppTitle() const override;
82 void Beep(uint32_t dwType) override;
83 int32_t MsgBox(const WideString& wsMessage,
84 const WideString& wsTitle,
85 uint32_t dwIconType,
86 uint32_t dwButtonType) override;
87 WideString Response(const WideString& wsQuestion,
88 const WideString& wsTitle,
89 const WideString& wsDefaultAnswer,
90 bool bMark) override;
92 const WideString& wsURL) override;
93 bool PostRequestURL(const WideString& wsURL,
94 const WideString& wsData,
95 const WideString& wsContentType,
96 const WideString& wsEncode,
97 const WideString& wsHeader,
98 WideString& wsResponse) override;
99 bool PutRequestURL(const WideString& wsURL,
100 const WideString& wsData,
101 const WideString& wsEncode) override;
102 CFX_Timer::HandlerIface* GetTimerHandler() const override;
103 cppgc::Heap* GetGCHeap() const override;
104
106 bool SaveFormPackage(const RetainPtr<IFX_SeekableStream>& pStream);
109 std::vector<RetainPtr<IFX_SeekableStream>>* fileList);
110
111 private:
112 CJS_Runtime* GetCJSRuntime() const;
113 bool SavePackage(const RetainPtr<IFX_SeekableStream>& pStream,
114 XFA_HashCode code);
115
116 FormType m_FormType = FormType::kNone;
117 LoadStatus m_nLoadStatus = LoadStatus::kPreload;
118 int m_nPageCount = 0;
119
120 // The order in which the following members are destroyed is critical.
121 UnownedPtr<CPDF_Document> const m_pPDFDoc;
122 std::unique_ptr<CFX_XMLDocument> m_pXML;
123 ObservedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
124 std::vector<RetainPtr<CPDFXFA_Page>> m_XFAPageList;
125
126 // Can't outlive |m_pFormFillEnv|.
127 std::unique_ptr<CPDFXFA_DocEnvironment> m_pDocEnv;
128
129 FXGCScopedHeap m_pGCHeap;
130 cppgc::Persistent<CXFA_FFApp> m_pXFAApp; // can't outlive |m_pGCHeap|
131 cppgc::Persistent<CXFA_FFDoc> m_pXFADoc; // Can't outlive |m_pGCHeap|
132 cppgc::Persistent<CXFA_FFDocView> m_pXFADocView; // Can't outlive |m_pGCHeap|
133};
134
135#endif // FPDFSDK_FPDFXFA_CPDFXFA_CONTEXT_H_
void BC_Library_Init()
void BC_Library_Destroy()
static void Destroy()
static void Create()
WideString GetPlatform() override
RetainPtr< IFX_SeekableReadStream > DownloadURL(const WideString &wsURL) override
bool PostRequestURL(const WideString &wsURL, const WideString &wsData, const WideString &wsContentType, const WideString &wsEncode, const WideString &wsHeader, WideString &wsResponse) override
RetainPtr< CPDFXFA_Page > GetXFAPage(CXFA_FFPageView *pPage) const
void SetOriginalPageCount(int count)
FormType GetFormType() const
WideString GetAppTitle() const override
WideString Response(const WideString &wsQuestion, const WideString &wsTitle, const WideString &wsDefaultAnswer, bool bMark) override
bool SaveDatasetsPackage(const RetainPtr< IFX_SeekableStream > &pStream)
~CPDFXFA_Context() override
void SetFormFillEnv(CPDFSDK_FormFillEnvironment *pFormFillEnv)
bool PutRequestURL(const WideString &wsURL, const WideString &wsData, const WideString &wsEncode) override
void SendPreSaveToXFADoc(std::vector< RetainPtr< IFX_SeekableStream > > *fileList)
CPDFSDK_FormFillEnvironment * GetFormFillEnv() const
CXFA_FFDocView * GetXFADocView() const
WideString GetAppName() override
bool SaveFormPackage(const RetainPtr< IFX_SeekableStream > &pStream)
CFX_Timer::HandlerIface * GetTimerHandler() const override
CXFA_FFDoc * GetXFADoc()
void Beep(uint32_t dwType) override
bool ContainsExtensionForegroundForm() const override
CPDFXFA_Context(CPDF_Document *pPDFDoc)
RetainPtr< CPDFXFA_Page > GetOrCreateXFAPage(int page_index)
bool ContainsExtensionForm() const override
int GetOriginalPageCount() const
WideString GetLanguage() override
RetainPtr< CPDFXFA_Page > GetXFAPage(int page_index)
void DeletePage(int page_index) override
LoadStatus GetLoadStatus() const
bool ContainsExtensionFullForm() const override
int GetPageCount() const override
cppgc::Heap * GetGCHeap() const override
CFX_XMLDocument * GetXMLDoc()
int32_t MsgBox(const WideString &wsMessage, const WideString &wsTitle, uint32_t dwIconType, uint32_t dwButtonType) override
CPDF_Document * GetPDFDoc() const
const CPDF_Dictionary * GetRoot() const
CXFA_Object * GetXFAObject(XFA_HashCode wsNodeNameHash)
CXFA_EventParam(XFA_EVENTTYPE type)
CXFA_FFWidgetHandler * GetWidgetHandler()
CXFA_FFDoc * GetDoc() const
CXFA_Node * GetRootSubform()
bool SavePackage(CXFA_Node *pNode, const RetainPtr< IFX_SeekableStream > &pFile)
CXFA_Document * GetXFADoc() const
Definition cxfa_ffdoc.h:167
XFA_EventError ProcessEvent(CXFA_Node *pNode, CXFA_EventParam *pParam)
CXFA_ReadyNodeIterator(CXFA_Node *pTravelRoot)
static WideString FromUTF16LE(pdfium::span< const uint8_t > data)
void CPDFXFA_ModuleInit()
void CPDFXFA_ModuleDestroy()
@ XFA_EVENT_PostSave
@ XFA_EVENT_PreSave
CXFA_Node * ToNode(CXFA_Object *pObj)
#define JSPLATFORM_ALERT_BUTTON_DEFAULT
#define JSPLATFORM_ALERT_ICON_ASTERISK
#define JSPLATFORM_ALERT_BUTTON_OKCANCEL
#define JSPLATFORM_ALERT_ICON_ERROR
#define JSPLATFORM_ALERT_BUTTON_YESNO
#define JSPLATFORM_ALERT_ICON_DEFAULT
#define JSPLATFORM_ALERT_ICON_WARNING
#define JSPLATFORM_ALERT_BUTTON_OK
#define JSPLATFORM_ALERT_ICON_QUESTION
#define JSPLATFORM_ALERT_ICON_STATUS
#define JSPLATFORM_ALERT_BUTTON_YESNOCANCEL
FormType
Definition fxfa.h:38
@ kXFAForeground
XFA_HashCode
Definition fxfa_basic.h:12
@ XFA_HASHCODE_Datasets
Definition fxfa_basic.h:19
@ XFA_HASHCODE_Form
Definition fxfa_basic.h:22
Definition heap.h:12