blob: af2bf2c796550dbd56109675355374ae9fc4a458 [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
dsinclair5b493092016-09-29 20:20:24 -07007#ifndef XFA_FXFA_XFA_FFDOC_H_
8#define XFA_FXFA_XFA_FFDOC_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
tsepez084174a2016-04-25 12:37:27 -070010#include <map>
11#include <memory>
12
dsinclair5b493092016-09-29 20:20:24 -070013#include "xfa/fxfa/fxfa.h"
dsinclair16280242016-07-21 12:03:47 -070014#include "xfa/fxfa/parser/cxfa_document.h"
dsinclair34f86b02016-07-11 08:42:33 -070015#include "xfa/fxfa/parser/cxfa_document_parser.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040016
dsinclairdf4bc592016-03-31 20:34:43 -070017class CXFA_ChecksumContext;
Dan Sinclair1770c022016-03-14 14:14:16 -040018class CXFA_FFApp;
19class CXFA_FFNotify;
20class CXFA_FFDocView;
21
22struct FX_IMAGEDIB_AND_DPI {
23 CFX_DIBSource* pDibSource;
24 int32_t iImageXDpi;
25 int32_t iImageYDpi;
26};
27
dsinclairdf4bc592016-03-31 20:34:43 -070028class CXFA_FFDoc {
Dan Sinclair1770c022016-03-14 14:14:16 -040029 public:
dsinclaira440bb32016-09-14 07:01:54 -070030 CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment);
Dan Sinclair1770c022016-03-14 14:14:16 -040031 ~CXFA_FFDoc();
dsinclair8837c912016-11-01 11:22:37 -070032
dsinclaira440bb32016-09-14 07:01:54 -070033 IXFA_DocEnvironment* GetDocEnvironment() const { return m_pDocEnvironment; }
tsepezdeee3d22016-03-25 14:38:58 -070034 uint32_t GetDocType();
dsinclair8837c912016-11-01 11:22:37 -070035 void SetDocType(uint32_t dwType);
36
Dan Sinclair1770c022016-03-14 14:14:16 -040037 int32_t StartLoad();
dsinclair85d1f2c2016-06-23 12:40:16 -070038 int32_t DoLoad(IFX_Pause* pPause = nullptr);
Dan Sinclair1770c022016-03-14 14:14:16 -040039 void StopLoad();
dsinclair8837c912016-11-01 11:22:37 -070040
Dan Sinclair3d060222017-03-22 15:29:20 -040041 CXFA_FFDocView* CreateDocView();
dsinclair8837c912016-11-01 11:22:37 -070042
tsepez833619b2016-12-07 09:21:17 -080043 bool OpenDoc(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream);
tsepezd19e9122016-11-02 15:43:18 -070044 bool OpenDoc(CPDF_Document* pPDFDoc);
45 bool CloseDoc();
dsinclair8837c912016-11-01 11:22:37 -070046
dsinclaira1b07722016-07-11 08:20:58 -070047 CXFA_Document* GetXFADoc() { return m_pDocumentParser->GetDocument(); }
Dan Sinclair1770c022016-03-14 14:14:16 -040048 CXFA_FFApp* GetApp() { return m_pApp; }
dsinclairdf4bc592016-03-31 20:34:43 -070049 CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout);
Dan Sinclair1770c022016-03-14 14:14:16 -040050 CXFA_FFDocView* GetDocView();
51 CPDF_Document* GetPDFDoc();
52 CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName,
53 int32_t& iImageXDpi,
54 int32_t& iImageYDpi);
dsinclaircbfef572016-05-18 13:16:12 -070055
56 bool SavePackage(XFA_HashCode code,
tsepez833619b2016-12-07 09:21:17 -080057 const CFX_RetainPtr<IFX_SeekableWriteStream>& pFile,
dsinclaircbfef572016-05-18 13:16:12 -070058 CXFA_ChecksumContext* pCSContext);
tsepez833619b2016-12-07 09:21:17 -080059 bool ImportData(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
60 bool bXDP = true);
Dan Sinclair1770c022016-03-14 14:14:16 -040061
62 protected:
dsinclaira440bb32016-09-14 07:01:54 -070063 IXFA_DocEnvironment* const m_pDocEnvironment;
dsinclaira1b07722016-07-11 08:20:58 -070064 std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser;
tsepez833619b2016-12-07 09:21:17 -080065 CFX_RetainPtr<IFX_SeekableReadStream> m_pStream;
Dan Sinclair1770c022016-03-14 14:14:16 -040066 CXFA_FFApp* m_pApp;
dsinclaira1b07722016-07-11 08:20:58 -070067 std::unique_ptr<CXFA_FFNotify> m_pNotify;
Dan Sinclair1770c022016-03-14 14:14:16 -040068 CPDF_Document* m_pPDFDoc;
tsepez084174a2016-04-25 12:37:27 -070069 std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap;
Dan Sinclair3d060222017-03-22 15:29:20 -040070 std::unique_ptr<CXFA_FFDocView> m_DocView;
tsepezdeee3d22016-03-25 14:38:58 -070071 uint32_t m_dwDocType;
Dan Sinclair1770c022016-03-14 14:14:16 -040072};
73
dsinclair5b493092016-09-29 20:20:24 -070074#endif // XFA_FXFA_XFA_FFDOC_H_