OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 FPDFSDK_INCLUDE_CPDFSDK_DOCUMENT_H_ |
| 8 #define FPDFSDK_INCLUDE_CPDFSDK_DOCUMENT_H_ |
| 9 |
| 10 #include <map> |
| 11 #include <memory> |
| 12 |
| 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 14 #include "core/fxcrt/include/cfx_observable.h" |
| 15 #include "fpdfsdk/include/fsdk_define.h" |
| 16 #include "public/fpdf_formfill.h" |
| 17 |
| 18 class CPDF_OCContext; |
| 19 class CPDFDoc_Environment; |
| 20 class CPDFSDK_Annot; |
| 21 class CPDFSDK_InterForm; |
| 22 class CPDFSDK_PageView; |
| 23 class IJS_Runtime; |
| 24 |
| 25 class CPDFSDK_Document : public CFX_Observable<CPDFSDK_Document> { |
| 26 public: |
| 27 static CPDFSDK_Document* FromFPDFFormHandle(FPDF_FORMHANDLE hHandle); |
| 28 |
| 29 CPDFSDK_Document(UnderlyingDocumentType* pDoc, CPDFDoc_Environment* pEnv); |
| 30 ~CPDFSDK_Document(); |
| 31 |
| 32 CPDFSDK_InterForm* GetInterForm(); |
| 33 |
| 34 // Gets the document object for the next layer down; for master this is |
| 35 // a CPDF_Document, but for XFA it is a CPDFXFA_Document. |
| 36 UnderlyingDocumentType* GetUnderlyingDocument() const { |
| 37 #ifdef PDF_ENABLE_XFA |
| 38 return GetXFADocument(); |
| 39 #else // PDF_ENABLE_XFA |
| 40 return GetPDFDocument(); |
| 41 #endif // PDF_ENABLE_XFA |
| 42 } |
| 43 |
| 44 // Gets the CPDF_Document, either directly in master, or from the |
| 45 // CPDFXFA_Document for XFA. |
| 46 CPDF_Document* GetPDFDocument() const { |
| 47 #ifdef PDF_ENABLE_XFA |
| 48 return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr; |
| 49 #else // PDF_ENABLE_XFA |
| 50 return m_pDoc; |
| 51 #endif // PDF_ENABLE_XFA |
| 52 } |
| 53 |
| 54 #ifdef PDF_ENABLE_XFA |
| 55 // Gets the XFA document directly (XFA-only). |
| 56 CPDFXFA_Document* GetXFADocument() const { return m_pDoc; } |
| 57 |
| 58 int GetPageViewCount() const { return m_pageMap.size(); } |
| 59 #endif // PDF_ENABLE_XFA |
| 60 |
| 61 CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, bool ReNew); |
| 62 CPDFSDK_PageView* GetPageView(int nIndex); |
| 63 CPDFSDK_PageView* GetCurrentView(); |
| 64 void RemovePageView(UnderlyingPageType* pPage); |
| 65 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); |
| 66 |
| 67 CPDFSDK_Annot* GetFocusAnnot(); |
| 68 |
| 69 IJS_Runtime* GetJsRuntime(); |
| 70 |
| 71 FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); |
| 72 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); |
| 73 |
| 74 FX_BOOL ExtractPages(const std::vector<uint16_t>& arrExtraPages, |
| 75 CPDF_Document* pDstDoc); |
| 76 FX_BOOL InsertPages(int nInsertAt, |
| 77 const CPDF_Document* pSrcDoc, |
| 78 const std::vector<uint16_t>& arrSrcPages); |
| 79 FX_BOOL ReplacePages(int nPage, |
| 80 const CPDF_Document* pSrcDoc, |
| 81 const std::vector<uint16_t>& arrSrcPages); |
| 82 |
| 83 void OnCloseDocument(); |
| 84 |
| 85 int GetPageCount() { return m_pDoc->GetPageCount(); } |
| 86 FX_BOOL GetPermissions(int nFlag); |
| 87 FX_BOOL GetChangeMark() { return m_bChangeMask; } |
| 88 void SetChangeMark() { m_bChangeMask = TRUE; } |
| 89 void ClearChangeMark() { m_bChangeMask = FALSE; } |
| 90 CFX_WideString GetPath(); |
| 91 UnderlyingPageType* GetPage(int nIndex); |
| 92 CPDFDoc_Environment* GetEnv() { return m_pEnv; } |
| 93 void ProcJavascriptFun(); |
| 94 FX_BOOL ProcOpenAction(); |
| 95 CPDF_OCContext* GetOCContext(); |
| 96 |
| 97 private: |
| 98 std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap; |
| 99 UnderlyingDocumentType* m_pDoc; |
| 100 std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; |
| 101 CPDFSDK_Annot* m_pFocusAnnot; |
| 102 CPDFDoc_Environment* m_pEnv; |
| 103 std::unique_ptr<CPDF_OCContext> m_pOccontent; |
| 104 FX_BOOL m_bChangeMask; |
| 105 FX_BOOL m_bBeingDestroyed; |
| 106 }; |
| 107 |
| 108 #endif // FPDFSDK_INCLUDE_CPDFSDK_DOCUMENT_H_ |
OLD | NEW |