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 7 #ifndef XFA_FXFA_XFA_FFDOC_H_ 8 #define XFA_FXFA_XFA_FFDOC_H_ 9 10 #include <map> 11 #include <memory> 12 13 #include "xfa/fxfa/fxfa.h" 14 #include "xfa/fxfa/parser/cxfa_document.h" 15 #include "xfa/fxfa/parser/cxfa_document_parser.h" 16 17 class CXFA_ChecksumContext; 18 class CXFA_FFApp; 19 class CXFA_FFNotify; 20 class CXFA_FFDocView; 21 22 struct FX_IMAGEDIB_AND_DPI { 23 CFX_DIBSource* pDibSource; 24 int32_t iImageXDpi; 25 int32_t iImageYDpi; 26 }; 27 28 class CXFA_FFDoc { 29 public: 30 CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment); 31 ~CXFA_FFDoc(); 32 GetDocEnvironment()33 IXFA_DocEnvironment* GetDocEnvironment() const { return m_pDocEnvironment; } 34 uint32_t GetDocType(); 35 void SetDocType(uint32_t dwType); 36 37 int32_t StartLoad(); 38 int32_t DoLoad(IFX_Pause* pPause = nullptr); 39 void StopLoad(); 40 41 CXFA_FFDocView* CreateDocView(uint32_t dwView = 0); 42 43 bool OpenDoc(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream); 44 bool OpenDoc(CPDF_Document* pPDFDoc); 45 bool CloseDoc(); 46 GetXFADoc()47 CXFA_Document* GetXFADoc() { return m_pDocumentParser->GetDocument(); } GetApp()48 CXFA_FFApp* GetApp() { return m_pApp; } 49 CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout); 50 CXFA_FFDocView* GetDocView(); 51 CPDF_Document* GetPDFDoc(); 52 CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName, 53 int32_t& iImageXDpi, 54 int32_t& iImageYDpi); 55 56 bool SavePackage(XFA_HashCode code, 57 const CFX_RetainPtr<IFX_SeekableWriteStream>& pFile, 58 CXFA_ChecksumContext* pCSContext); 59 bool ImportData(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream, 60 bool bXDP = true); 61 62 protected: 63 IXFA_DocEnvironment* const m_pDocEnvironment; 64 std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser; 65 CFX_RetainPtr<IFX_SeekableReadStream> m_pStream; 66 CXFA_FFApp* m_pApp; 67 std::unique_ptr<CXFA_FFNotify> m_pNotify; 68 CPDF_Document* m_pPDFDoc; 69 std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap; 70 std::map<uint32_t, std::unique_ptr<CXFA_FFDocView>> m_TypeToDocViewMap; 71 uint32_t m_dwDocType; 72 }; 73 74 #endif // XFA_FXFA_XFA_FFDOC_H_ 75