From 521b7508dfe8ab93975eeb9f4ef8068012c4dbd8 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 2 Nov 2016 13:02:28 -0700 Subject: Rename CPDFXFA_Document to CPDFXFA_Context The CPDFXFA_Document class isn't a document, it contains documents. Renamed to make the purpose a bit clearer. Review-Url: https://codereview.chromium.org/2469813004 --- fpdfsdk/fpdfxfa/cpdfxfa_context.h | 116 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 fpdfsdk/fpdfxfa/cpdfxfa_context.h (limited to 'fpdfsdk/fpdfxfa/cpdfxfa_context.h') diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h new file mode 100644 index 0000000000..02588e3fad --- /dev/null +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -0,0 +1,116 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FPDFXFA_CPDFXFA_CONTEXT_H_ +#define FPDFSDK_FPDFXFA_CPDFXFA_CONTEXT_H_ + +#include + +#include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" +#include "xfa/fxfa/xfa_ffdoc.h" + +class CJS_Runtime; +class CPDFSDK_FormFillEnvironment; +class CPDFXFA_Page; +class CXFA_FFDocHandler; +class IJS_Runtime; +class IJS_Context; + +enum LoadStatus { + FXFA_LOADSTATUS_PRELOAD = 0, + FXFA_LOADSTATUS_LOADING, + FXFA_LOADSTATUS_LOADED, + FXFA_LOADSTATUS_CLOSING, + FXFA_LOADSTATUS_CLOSED +}; + +class CPDFXFA_Context : public IXFA_AppProvider { + public: + CPDFXFA_Context(std::unique_ptr pPDFDoc); + ~CPDFXFA_Context() override; + + FX_BOOL LoadXFADoc(); + CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } + CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } + CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } + int GetDocType() const { return m_iDocType; } + v8::Isolate* GetJSERuntime() const; + CXFA_FFApp* GetXFAApp() { return m_pXFAApp.get(); } + + CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; } + void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv); + + void DeletePage(int page_index); + int GetPageCount() const; + + CPDFXFA_Page* GetXFAPage(int page_index); + CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; + + void RemovePage(CPDFXFA_Page* page); + + void ClearChangeMark(); + + // IFXA_AppProvider: + void GetLanguage(CFX_WideString& wsLanguage) override; + void GetPlatform(CFX_WideString& wsPlatform) override; + void GetAppName(CFX_WideString& wsName) override; + + void Beep(uint32_t dwType) override; + int32_t MsgBox(const CFX_WideString& wsMessage, + const CFX_WideString& wsTitle, + uint32_t dwIconType, + uint32_t dwButtonType) override; + CFX_WideString Response(const CFX_WideString& wsQuestion, + const CFX_WideString& wsTitle, + const CFX_WideString& wsDefaultAnswer, + FX_BOOL bMark) override; + IFX_SeekableReadStream* DownloadURL(const CFX_WideString& wsURL) override; + FX_BOOL PostRequestURL(const CFX_WideString& wsURL, + const CFX_WideString& wsData, + const CFX_WideString& wsContentType, + const CFX_WideString& wsEncode, + const CFX_WideString& wsHeader, + CFX_WideString& wsResponse) override; + FX_BOOL PutRequestURL(const CFX_WideString& wsURL, + const CFX_WideString& wsData, + const CFX_WideString& wsEncode) override; + + void LoadString(int32_t iStringID, CFX_WideString& wsString) override; + IFWL_AdapterTimerMgr* GetTimerMgr() override; + + protected: + friend class CPDFXFA_DocEnvironment; + + int GetOriginalPageCount() const { return m_nPageCount; } + void SetOriginalPageCount(int count) { + m_nPageCount = count; + m_XFAPageList.SetSize(count); + } + + LoadStatus GetLoadStatus() const { return m_nLoadStatus; } + + CFX_ArrayTemplate* GetXFAPageList() { return &m_XFAPageList; } + + private: + void CloseXFADoc(); + + int m_iDocType; + + std::unique_ptr m_pPDFDoc; + std::unique_ptr m_pXFADoc; + CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned. + CXFA_FFDocView* m_pXFADocView; // not owned. + std::unique_ptr m_pXFAApp; + std::unique_ptr m_pRuntime; + CFX_ArrayTemplate m_XFAPageList; + LoadStatus m_nLoadStatus; + int m_nPageCount; + + // Must be destroyed before |m_pFormFillEnv|. + CPDFXFA_DocEnvironment m_DocEnv; +}; + +#endif // FPDFSDK_FPDFXFA_CPDFXFA_CONTEXT_H_ -- cgit v1.2.3