Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 1 | // 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 Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 7 | #ifndef XFA_FXFA_CXFA_FFDOC_H_ |
| 8 | #define XFA_FXFA_CXFA_FFDOC_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
tsepez | 084174a | 2016-04-25 12:37:27 -0700 | [diff] [blame] | 10 | #include <map> |
| 11 | #include <memory> |
| 12 | |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 13 | #include "core/fxcrt/unowned_ptr.h" |
dsinclair | 5b49309 | 2016-09-29 20:20:24 -0700 | [diff] [blame] | 14 | #include "xfa/fxfa/fxfa.h" |
dsinclair | 1628024 | 2016-07-21 12:03:47 -0700 | [diff] [blame] | 15 | #include "xfa/fxfa/parser/cxfa_document.h" |
dsinclair | 34f86b0 | 2016-07-11 08:42:33 -0700 | [diff] [blame] | 16 | #include "xfa/fxfa/parser/cxfa_document_parser.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 17 | |
Dan Sinclair | a44a480 | 2017-09-21 10:45:18 -0400 | [diff] [blame] | 18 | class CFGAS_PDFFontMgr; |
Dan Sinclair | ddb7016 | 2017-03-30 14:01:31 -0400 | [diff] [blame] | 19 | class CFX_ChecksumContext; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 20 | class CXFA_FFApp; |
| 21 | class CXFA_FFNotify; |
| 22 | class CXFA_FFDocView; |
| 23 | |
| 24 | struct FX_IMAGEDIB_AND_DPI { |
Tom Sepez | f0799fe | 2017-03-28 09:31:32 -0700 | [diff] [blame] | 25 | FX_IMAGEDIB_AND_DPI(); |
| 26 | FX_IMAGEDIB_AND_DPI(const FX_IMAGEDIB_AND_DPI& that); |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 27 | FX_IMAGEDIB_AND_DPI(const RetainPtr<CFX_DIBSource>& pDib, |
Tom Sepez | f0799fe | 2017-03-28 09:31:32 -0700 | [diff] [blame] | 28 | int32_t xDpi, |
| 29 | int32_t yDpi); |
| 30 | ~FX_IMAGEDIB_AND_DPI(); |
| 31 | |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 32 | RetainPtr<CFX_DIBSource> pDibSource; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 33 | int32_t iImageXDpi; |
| 34 | int32_t iImageYDpi; |
| 35 | }; |
| 36 | |
Tom Sepez | f0799fe | 2017-03-28 09:31:32 -0700 | [diff] [blame] | 37 | inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI() = default; |
| 38 | inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI( |
| 39 | const FX_IMAGEDIB_AND_DPI& that) = default; |
| 40 | |
| 41 | inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI( |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 42 | const RetainPtr<CFX_DIBSource>& pDib, |
Tom Sepez | f0799fe | 2017-03-28 09:31:32 -0700 | [diff] [blame] | 43 | int32_t xDpi, |
| 44 | int32_t yDpi) |
| 45 | : pDibSource(pDib), iImageXDpi(xDpi), iImageYDpi(yDpi) {} |
| 46 | |
| 47 | inline FX_IMAGEDIB_AND_DPI::~FX_IMAGEDIB_AND_DPI() = default; |
| 48 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 49 | class CXFA_FFDoc { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 50 | public: |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 51 | CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 52 | ~CXFA_FFDoc(); |
dsinclair | 8837c91 | 2016-11-01 11:22:37 -0700 | [diff] [blame] | 53 | |
Tom Sepez | dc8a2b7 | 2017-05-24 13:45:11 -0700 | [diff] [blame] | 54 | IXFA_DocEnvironment* GetDocEnvironment() const { |
| 55 | return m_pDocEnvironment.Get(); |
| 56 | } |
Ryan Harrison | 854d71c | 2017-10-18 12:28:14 -0400 | [diff] [blame^] | 57 | FormType GetFormType() const { return m_FormType; } |
dsinclair | 8837c91 | 2016-11-01 11:22:37 -0700 | [diff] [blame] | 58 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 59 | int32_t StartLoad(); |
Dan Sinclair | df673c2 | 2017-05-04 12:09:52 -0400 | [diff] [blame] | 60 | int32_t DoLoad(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 61 | void StopLoad(); |
dsinclair | 8837c91 | 2016-11-01 11:22:37 -0700 | [diff] [blame] | 62 | |
Dan Sinclair | 3d06022 | 2017-03-22 15:29:20 -0400 | [diff] [blame] | 63 | CXFA_FFDocView* CreateDocView(); |
dsinclair | 8837c91 | 2016-11-01 11:22:37 -0700 | [diff] [blame] | 64 | |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 65 | bool OpenDoc(CPDF_Document* pPDFDoc); |
Tom Sepez | cc20513 | 2017-05-16 14:01:47 -0700 | [diff] [blame] | 66 | void CloseDoc(); |
dsinclair | 8837c91 | 2016-11-01 11:22:37 -0700 | [diff] [blame] | 67 | |
Tom Sepez | dc8a2b7 | 2017-05-24 13:45:11 -0700 | [diff] [blame] | 68 | 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(); } |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 71 | CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 72 | CXFA_FFDocView* GetDocView(); |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 73 | RetainPtr<CFX_DIBitmap> GetPDFNamedImage(const WideStringView& wsName, |
| 74 | int32_t& iImageXDpi, |
| 75 | int32_t& iImageYDpi); |
Dan Sinclair | a44a480 | 2017-09-21 10:45:18 -0400 | [diff] [blame] | 76 | CFGAS_PDFFontMgr* GetPDFFontMgr() const { return m_pPDFFontMgr.get(); } |
dsinclair | cbfef57 | 2016-05-18 13:16:12 -0700 | [diff] [blame] | 77 | |
| 78 | bool SavePackage(XFA_HashCode code, |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 79 | const RetainPtr<IFX_SeekableStream>& pFile, |
Dan Sinclair | ddb7016 | 2017-03-30 14:01:31 -0400 | [diff] [blame] | 80 | CFX_ChecksumContext* pCSContext); |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 81 | bool ImportData(const RetainPtr<IFX_SeekableStream>& pStream, |
tsepez | 833619b | 2016-12-07 09:21:17 -0800 | [diff] [blame] | 82 | bool bXDP = true); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 83 | |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 84 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 85 | UnownedPtr<IXFA_DocEnvironment> const m_pDocEnvironment; |
dsinclair | a1b0772 | 2016-07-11 08:20:58 -0700 | [diff] [blame] | 86 | std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser; |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 87 | RetainPtr<IFX_SeekableStream> m_pStream; |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 88 | UnownedPtr<CXFA_FFApp> m_pApp; |
dsinclair | a1b0772 | 2016-07-11 08:20:58 -0700 | [diff] [blame] | 89 | std::unique_ptr<CXFA_FFNotify> m_pNotify; |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 90 | UnownedPtr<CPDF_Document> m_pPDFDoc; |
tsepez | 084174a | 2016-04-25 12:37:27 -0700 | [diff] [blame] | 91 | std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap; |
Dan Sinclair | 3d06022 | 2017-03-22 15:29:20 -0400 | [diff] [blame] | 92 | std::unique_ptr<CXFA_FFDocView> m_DocView; |
Dan Sinclair | a44a480 | 2017-09-21 10:45:18 -0400 | [diff] [blame] | 93 | std::unique_ptr<CFGAS_PDFFontMgr> m_pPDFFontMgr; |
Ryan Harrison | 854d71c | 2017-10-18 12:28:14 -0400 | [diff] [blame^] | 94 | FormType m_FormType; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 95 | }; |
| 96 | |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 97 | #endif // XFA_FXFA_CXFA_FFDOC_H_ |