From 114e46a1d97587973515e9aad7955e469c7486a8 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 29 Sep 2016 17:18:21 -0700 Subject: Move fpdfsdk/include to fpdfsdk BUG=pdfium:611 Review-Url: https://codereview.chromium.org/2384503003 --- fpdfsdk/cpdfsdk_document.h | 108 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 fpdfsdk/cpdfsdk_document.h (limited to 'fpdfsdk/cpdfsdk_document.h') diff --git a/fpdfsdk/cpdfsdk_document.h b/fpdfsdk/cpdfsdk_document.h new file mode 100644 index 0000000000..f693588da0 --- /dev/null +++ b/fpdfsdk/cpdfsdk_document.h @@ -0,0 +1,108 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_CPDFSDK_DOCUMENT_H_ +#define FPDFSDK_CPDFSDK_DOCUMENT_H_ + +#include +#include + +#include "core/fpdfapi/fpdf_parser/cpdf_document.h" +#include "core/fxcrt/cfx_observable.h" +#include "fpdfsdk/cpdfsdk_annot.h" +#include "fpdfsdk/fsdk_define.h" +#include "public/fpdf_formfill.h" + +class CPDF_OCContext; +class CPDFSDK_Environment; +class CPDFSDK_InterForm; +class CPDFSDK_PageView; +class IJS_Runtime; + +class CPDFSDK_Document : public CFX_Observable { + public: + static CPDFSDK_Document* FromFPDFFormHandle(FPDF_FORMHANDLE hHandle); + + CPDFSDK_Document(UnderlyingDocumentType* pDoc, CPDFSDK_Environment* pEnv); + ~CPDFSDK_Document(); + + CPDFSDK_InterForm* GetInterForm(); + + // Gets the document object for the next layer down; for master this is + // a CPDF_Document, but for XFA it is a CPDFXFA_Document. + UnderlyingDocumentType* GetUnderlyingDocument() const { +#ifdef PDF_ENABLE_XFA + return GetXFADocument(); +#else // PDF_ENABLE_XFA + return GetPDFDocument(); +#endif // PDF_ENABLE_XFA + } + + // Gets the CPDF_Document, either directly in master, or from the + // CPDFXFA_Document for XFA. + CPDF_Document* GetPDFDocument() const { +#ifdef PDF_ENABLE_XFA + return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr; +#else // PDF_ENABLE_XFA + return m_pDoc; +#endif // PDF_ENABLE_XFA + } + +#ifdef PDF_ENABLE_XFA + // Gets the XFA document directly (XFA-only). + CPDFXFA_Document* GetXFADocument() const { return m_pDoc; } + + int GetPageViewCount() const { return m_pageMap.size(); } +#endif // PDF_ENABLE_XFA + + CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, bool ReNew); + CPDFSDK_PageView* GetPageView(int nIndex); + CPDFSDK_PageView* GetCurrentView(); + void RemovePageView(UnderlyingPageType* pPage); + void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); + + CPDFSDK_Annot* GetFocusAnnot(); + + IJS_Runtime* GetJsRuntime(); + + FX_BOOL SetFocusAnnot(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag = 0); + FX_BOOL KillFocusAnnot(uint32_t nFlag = 0); + + FX_BOOL ExtractPages(const std::vector& arrExtraPages, + CPDF_Document* pDstDoc); + FX_BOOL InsertPages(int nInsertAt, + const CPDF_Document* pSrcDoc, + const std::vector& arrSrcPages); + FX_BOOL ReplacePages(int nPage, + const CPDF_Document* pSrcDoc, + const std::vector& arrSrcPages); + + void OnCloseDocument(); + + int GetPageCount() { return m_pDoc->GetPageCount(); } + FX_BOOL GetPermissions(int nFlag); + FX_BOOL GetChangeMark() { return m_bChangeMask; } + void SetChangeMark() { m_bChangeMask = TRUE; } + void ClearChangeMark() { m_bChangeMask = FALSE; } + CFX_WideString GetPath(); + UnderlyingPageType* GetPage(int nIndex); + CPDFSDK_Environment* GetEnv() { return m_pEnv; } + void ProcJavascriptFun(); + FX_BOOL ProcOpenAction(); + CPDF_OCContext* GetOCContext(); + + private: + std::map m_pageMap; + UnderlyingDocumentType* m_pDoc; + std::unique_ptr m_pInterForm; + CPDFSDK_Annot::ObservedPtr m_pFocusAnnot; + CPDFSDK_Environment* m_pEnv; + std::unique_ptr m_pOccontent; + FX_BOOL m_bChangeMask; + FX_BOOL m_bBeingDestroyed; +}; + +#endif // FPDFSDK_CPDFSDK_DOCUMENT_H_ -- cgit v1.2.3