blob: 490b023f0d271c23fba449be9f602389803fbf50 [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// Copyright 2014 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
Dan Sinclair80c48782017-03-23 12:11:20 -04007#ifndef XFA_FXFA_CXFA_FFDOC_H_
8#define XFA_FXFA_CXFA_FFDOC_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
tsepez084174a2016-04-25 12:37:27 -070010#include <map>
11#include <memory>
12
Dan Sinclairaee0db02017-09-21 16:53:58 -040013#include "core/fxcrt/unowned_ptr.h"
dsinclair5b493092016-09-29 20:20:24 -070014#include "xfa/fxfa/fxfa.h"
dsinclair16280242016-07-21 12:03:47 -070015#include "xfa/fxfa/parser/cxfa_document.h"
dsinclair34f86b02016-07-11 08:42:33 -070016#include "xfa/fxfa/parser/cxfa_document_parser.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040017
Dan Sinclaira44a4802017-09-21 10:45:18 -040018class CFGAS_PDFFontMgr;
Dan Sinclairddb70162017-03-30 14:01:31 -040019class CFX_ChecksumContext;
Dan Sinclair1770c022016-03-14 14:14:16 -040020class CXFA_FFApp;
21class CXFA_FFNotify;
22class CXFA_FFDocView;
23
24struct FX_IMAGEDIB_AND_DPI {
Tom Sepezf0799fe2017-03-28 09:31:32 -070025 FX_IMAGEDIB_AND_DPI();
26 FX_IMAGEDIB_AND_DPI(const FX_IMAGEDIB_AND_DPI& that);
Dan Sinclair0b950422017-09-21 15:49:49 -040027 FX_IMAGEDIB_AND_DPI(const RetainPtr<CFX_DIBSource>& pDib,
Tom Sepezf0799fe2017-03-28 09:31:32 -070028 int32_t xDpi,
29 int32_t yDpi);
30 ~FX_IMAGEDIB_AND_DPI();
31
Dan Sinclair0b950422017-09-21 15:49:49 -040032 RetainPtr<CFX_DIBSource> pDibSource;
Dan Sinclair1770c022016-03-14 14:14:16 -040033 int32_t iImageXDpi;
34 int32_t iImageYDpi;
35};
36
Tom Sepezf0799fe2017-03-28 09:31:32 -070037inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI() = default;
38inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI(
39 const FX_IMAGEDIB_AND_DPI& that) = default;
40
41inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI(
Dan Sinclair0b950422017-09-21 15:49:49 -040042 const RetainPtr<CFX_DIBSource>& pDib,
Tom Sepezf0799fe2017-03-28 09:31:32 -070043 int32_t xDpi,
44 int32_t yDpi)
45 : pDibSource(pDib), iImageXDpi(xDpi), iImageYDpi(yDpi) {}
46
47inline FX_IMAGEDIB_AND_DPI::~FX_IMAGEDIB_AND_DPI() = default;
48
dsinclairdf4bc592016-03-31 20:34:43 -070049class CXFA_FFDoc {
Dan Sinclair1770c022016-03-14 14:14:16 -040050 public:
dsinclaira440bb32016-09-14 07:01:54 -070051 CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment);
Dan Sinclair1770c022016-03-14 14:14:16 -040052 ~CXFA_FFDoc();
dsinclair8837c912016-11-01 11:22:37 -070053
Tom Sepezdc8a2b72017-05-24 13:45:11 -070054 IXFA_DocEnvironment* GetDocEnvironment() const {
55 return m_pDocEnvironment.Get();
56 }
Ryan Harrison854d71c2017-10-18 12:28:14 -040057 FormType GetFormType() const { return m_FormType; }
dsinclair8837c912016-11-01 11:22:37 -070058
Dan Sinclair1770c022016-03-14 14:14:16 -040059 int32_t StartLoad();
Dan Sinclairdf673c22017-05-04 12:09:52 -040060 int32_t DoLoad();
Dan Sinclair1770c022016-03-14 14:14:16 -040061 void StopLoad();
dsinclair8837c912016-11-01 11:22:37 -070062
Dan Sinclair3d060222017-03-22 15:29:20 -040063 CXFA_FFDocView* CreateDocView();
dsinclair8837c912016-11-01 11:22:37 -070064
tsepezd19e9122016-11-02 15:43:18 -070065 bool OpenDoc(CPDF_Document* pPDFDoc);
Tom Sepezcc205132017-05-16 14:01:47 -070066 void CloseDoc();
dsinclair8837c912016-11-01 11:22:37 -070067
Tom Sepezdc8a2b72017-05-24 13:45:11 -070068 CXFA_Document* GetXFADoc() const { return m_pDocumentParser->GetDocument(); }
69 CXFA_FFApp* GetApp() const { return m_pApp.Get(); }
70 CPDF_Document* GetPDFDoc() const { return m_pPDFDoc.Get(); }
dsinclairdf4bc592016-03-31 20:34:43 -070071 CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout);
Dan Sinclair1770c022016-03-14 14:14:16 -040072 CXFA_FFDocView* GetDocView();
Dan Sinclair0b950422017-09-21 15:49:49 -040073 RetainPtr<CFX_DIBitmap> GetPDFNamedImage(const WideStringView& wsName,
74 int32_t& iImageXDpi,
75 int32_t& iImageYDpi);
Dan Sinclaira44a4802017-09-21 10:45:18 -040076 CFGAS_PDFFontMgr* GetPDFFontMgr() const { return m_pPDFFontMgr.get(); }
dsinclaircbfef572016-05-18 13:16:12 -070077
78 bool SavePackage(XFA_HashCode code,
Dan Sinclair0b950422017-09-21 15:49:49 -040079 const RetainPtr<IFX_SeekableStream>& pFile,
Dan Sinclairddb70162017-03-30 14:01:31 -040080 CFX_ChecksumContext* pCSContext);
Dan Sinclair0b950422017-09-21 15:49:49 -040081 bool ImportData(const RetainPtr<IFX_SeekableStream>& pStream,
tsepez833619b2016-12-07 09:21:17 -080082 bool bXDP = true);
Dan Sinclair1770c022016-03-14 14:14:16 -040083
Dan Sinclair80c48782017-03-23 12:11:20 -040084 private:
Dan Sinclairaee0db02017-09-21 16:53:58 -040085 UnownedPtr<IXFA_DocEnvironment> const m_pDocEnvironment;
dsinclaira1b07722016-07-11 08:20:58 -070086 std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser;
Dan Sinclair0b950422017-09-21 15:49:49 -040087 RetainPtr<IFX_SeekableStream> m_pStream;
Dan Sinclairaee0db02017-09-21 16:53:58 -040088 UnownedPtr<CXFA_FFApp> m_pApp;
dsinclaira1b07722016-07-11 08:20:58 -070089 std::unique_ptr<CXFA_FFNotify> m_pNotify;
Dan Sinclairaee0db02017-09-21 16:53:58 -040090 UnownedPtr<CPDF_Document> m_pPDFDoc;
tsepez084174a2016-04-25 12:37:27 -070091 std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap;
Dan Sinclair3d060222017-03-22 15:29:20 -040092 std::unique_ptr<CXFA_FFDocView> m_DocView;
Dan Sinclaira44a4802017-09-21 10:45:18 -040093 std::unique_ptr<CFGAS_PDFFontMgr> m_pPDFFontMgr;
Ryan Harrison854d71c2017-10-18 12:28:14 -040094 FormType m_FormType;
Dan Sinclair1770c022016-03-14 14:14:16 -040095};
96
Dan Sinclair80c48782017-03-23 12:11:20 -040097#endif // XFA_FXFA_CXFA_FFDOC_H_