• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CXFA_FFDOC_H_
8 #define XFA_FXFA_CXFA_FFDOC_H_
9 
10 #include <map>
11 #include <memory>
12 
13 #include "core/fxcrt/unowned_ptr.h"
14 #include "xfa/fxfa/fxfa.h"
15 #include "xfa/fxfa/parser/cxfa_document.h"
16 #include "xfa/fxfa/parser/cxfa_document_parser.h"
17 
18 class CFGAS_PDFFontMgr;
19 class CFX_ChecksumContext;
20 class CPDF_Document;
21 class CXFA_FFApp;
22 class CXFA_FFNotify;
23 class CXFA_FFDocView;
24 
25 struct FX_IMAGEDIB_AND_DPI {
26   FX_IMAGEDIB_AND_DPI();
27   FX_IMAGEDIB_AND_DPI(const FX_IMAGEDIB_AND_DPI& that);
28   FX_IMAGEDIB_AND_DPI(const RetainPtr<CFX_DIBSource>& pDib,
29                       int32_t xDpi,
30                       int32_t yDpi);
31   ~FX_IMAGEDIB_AND_DPI();
32 
33   RetainPtr<CFX_DIBSource> pDibSource;
34   int32_t iImageXDpi;
35   int32_t iImageYDpi;
36 };
37 
38 inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI() = default;
39 inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI(
40     const FX_IMAGEDIB_AND_DPI& that) = default;
41 
FX_IMAGEDIB_AND_DPI(const RetainPtr<CFX_DIBSource> & pDib,int32_t xDpi,int32_t yDpi)42 inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI(
43     const RetainPtr<CFX_DIBSource>& pDib,
44     int32_t xDpi,
45     int32_t yDpi)
46     : pDibSource(pDib), iImageXDpi(xDpi), iImageYDpi(yDpi) {}
47 
48 inline FX_IMAGEDIB_AND_DPI::~FX_IMAGEDIB_AND_DPI() = default;
49 
50 class CXFA_FFDoc {
51  public:
52   CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment);
53   ~CXFA_FFDoc();
54 
GetDocEnvironment()55   IXFA_DocEnvironment* GetDocEnvironment() const {
56     return m_pDocEnvironment.Get();
57   }
GetFormType()58   FormType GetFormType() const { return m_FormType; }
59 
60   int32_t StartLoad();
61   int32_t DoLoad();
62   void StopLoad();
63 
64   CXFA_FFDocView* CreateDocView();
65 
66   bool OpenDoc(CPDF_Document* pPDFDoc);
67   void CloseDoc();
68 
GetXFADoc()69   CXFA_Document* GetXFADoc() const { return m_pDocumentParser->GetDocument(); }
GetApp()70   CXFA_FFApp* GetApp() const { return m_pApp.Get(); }
GetPDFDoc()71   CPDF_Document* GetPDFDoc() const { return m_pPDFDoc.Get(); }
72   CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout);
73   CXFA_FFDocView* GetDocView();
74   RetainPtr<CFX_DIBitmap> GetPDFNamedImage(const WideStringView& wsName,
75                                            int32_t& iImageXDpi,
76                                            int32_t& iImageYDpi);
GetPDFFontMgr()77   CFGAS_PDFFontMgr* GetPDFFontMgr() const { return m_pPDFFontMgr.get(); }
78 
79   bool SavePackage(CXFA_Node* pNode,
80                    const RetainPtr<IFX_SeekableStream>& pFile,
81                    CFX_ChecksumContext* pCSContext);
82   bool ImportData(const RetainPtr<IFX_SeekableStream>& pStream,
83                   bool bXDP = true);
84 
85  private:
86   UnownedPtr<IXFA_DocEnvironment> const m_pDocEnvironment;
87   std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser;
88   RetainPtr<IFX_SeekableStream> m_pStream;
89   UnownedPtr<CXFA_FFApp> const m_pApp;
90   std::unique_ptr<CXFA_FFNotify> m_pNotify;
91   UnownedPtr<CPDF_Document> m_pPDFDoc;
92   std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap;
93   std::unique_ptr<CXFA_FFDocView> m_DocView;
94   std::unique_ptr<CFGAS_PDFFontMgr> m_pPDFFontMgr;
95   FormType m_FormType = FormType::kXFAForeground;
96 };
97 
98 #endif  // XFA_FXFA_CXFA_FFDOC_H_
99