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