chromium/third_party/pdfium/core/fpdfapi/parser/cpdf_document.cpp

// Copyright 2014 The PDFium Authors
// 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

#include "core/fpdfapi/parser/cpdf_document.h"

#include <algorithm>
#include <functional>
#include <optional>
#include <utility>

#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_linearized_header.h"
#include "core/fpdfapi/parser/cpdf_name.h"
#include "core/fpdfapi/parser/cpdf_null.h"
#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/cpdf_parser.h"
#include "core/fpdfapi/parser/cpdf_read_validator.h"
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fxcodec/jbig2/JBig2_DocumentContext.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/containers/contains.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/scoped_set_insertion.h"
#include "core/fxcrt/span.h"
#include "core/fxcrt/stl_util.h"

namespace {

const int kMaxPageLevel =;

enum class NodeType : bool {};

// Note that this function may modify `kid_dict` to correct PDF spec violations.
// Same reasoning as CountPages() below.
NodeType GetNodeType(RetainPtr<CPDF_Dictionary> kid_dict) {}

// Returns a value in the range [0, `CPDF_Document::kPageMaxNum`), or nullopt on
// error. Note that this function may modify `pages_dict` to correct PDF spec
// violations. By normalizing the in-memory representation, other code that
// reads the object do not have to deal with the same spec violations again.
// If the PDF gets saved, the saved copy will also be more spec-compliant.
std::optional<int> CountPages(
    RetainPtr<CPDF_Dictionary> pages_dict,
    std::set<RetainPtr<CPDF_Dictionary>>* visited_pages) {}

int FindPageIndex(const CPDF_Dictionary* pNode,
                  uint32_t* skip_count,
                  uint32_t objnum,
                  int* index,
                  int level) {}

}  // namespace

CPDF_Document::CPDF_Document(std::unique_ptr<RenderDataIface> pRenderData,
                             std::unique_ptr<PageDataIface> pPageData)
    :{}

CPDF_Document::~CPDF_Document() {}

// static
bool CPDF_Document::IsValidPageObject(const CPDF_Object* obj) {}

RetainPtr<CPDF_Object> CPDF_Document::ParseIndirectObject(uint32_t objnum) {}

bool CPDF_Document::TryInit() {}

CPDF_Parser::Error CPDF_Document::LoadDoc(
    RetainPtr<IFX_SeekableReadStream> pFileAccess,
    const ByteString& password) {}

CPDF_Parser::Error CPDF_Document::LoadLinearizedDoc(
    RetainPtr<CPDF_ReadValidator> validator,
    const ByteString& password) {}

void CPDF_Document::LoadPages() {}

RetainPtr<CPDF_Dictionary> CPDF_Document::TraversePDFPages(int iPage,
                                                           int* nPagesToGo,
                                                           size_t level) {}

void CPDF_Document::ResetTraversal() {}

void CPDF_Document::SetParser(std::unique_ptr<CPDF_Parser> pParser) {}

CPDF_Parser::Error CPDF_Document::HandleLoadResult(CPDF_Parser::Error error) {}

RetainPtr<const CPDF_Dictionary> CPDF_Document::GetPagesDict() const {}

RetainPtr<CPDF_Dictionary> CPDF_Document::GetMutablePagesDict() {}

bool CPDF_Document::IsPageLoaded(int iPage) const {}

RetainPtr<const CPDF_Dictionary> CPDF_Document::GetPageDictionary(int iPage) {}

RetainPtr<CPDF_Dictionary> CPDF_Document::GetMutablePageDictionary(int iPage) {}

void CPDF_Document::SetPageObjNum(int iPage, uint32_t objNum) {}

JBig2_DocumentContext* CPDF_Document::GetOrCreateCodecContext() {}

RetainPtr<CPDF_Stream> CPDF_Document::CreateModifiedAPStream(
    RetainPtr<CPDF_Dictionary> dict) {}

bool CPDF_Document::IsModifiedAPStream(const CPDF_Stream* stream) const {}

int CPDF_Document::GetPageIndex(uint32_t objnum) {}

int CPDF_Document::GetPageCount() const {}

int CPDF_Document::RetrievePageCount() {}

uint32_t CPDF_Document::GetUserPermissions(bool get_owner_perms) const {}

RetainPtr<CPDF_StreamAcc> CPDF_Document::GetFontFileStreamAcc(
    RetainPtr<const CPDF_Stream> pFontStream) {}

void CPDF_Document::MaybePurgeFontFileStreamAcc(
    RetainPtr<CPDF_StreamAcc>&& pStreamAcc) {}

void CPDF_Document::MaybePurgeImage(uint32_t objnum) {}

void CPDF_Document::CreateNewDoc() {}

RetainPtr<CPDF_Dictionary> CPDF_Document::CreateNewPage(int iPage) {}

bool CPDF_Document::InsertDeletePDFPage(
    RetainPtr<CPDF_Dictionary> pages_dict,
    int pages_to_go,
    RetainPtr<CPDF_Dictionary> page_dict,
    bool is_insert,
    std::set<RetainPtr<CPDF_Dictionary>>* visited) {}

bool CPDF_Document::InsertNewPage(int iPage,
                                  RetainPtr<CPDF_Dictionary> pPageDict) {}

RetainPtr<CPDF_Dictionary> CPDF_Document::GetInfo() {}

RetainPtr<const CPDF_Array> CPDF_Document::GetFileIdentifier() const {}

uint32_t CPDF_Document::DeletePage(int iPage) {}

void CPDF_Document::SetPageToNullObject(uint32_t page_obj_num) {}

void CPDF_Document::SetRootForTesting(RetainPtr<CPDF_Dictionary> root) {}

bool CPDF_Document::MovePages(pdfium::span<const int> page_indices,
                              int dest_page_index) {}

void CPDF_Document::ResizePageListForTesting(size_t size) {}

CPDF_Document::StockFontClearer::StockFontClearer(
    CPDF_Document::PageDataIface* pPageData)
    :{}

CPDF_Document::StockFontClearer::~StockFontClearer() {}

CPDF_Document::PageDataIface::PageDataIface() = default;

CPDF_Document::PageDataIface::~PageDataIface() = default;

CPDF_Document::RenderDataIface::RenderDataIface() = default;

CPDF_Document::RenderDataIface::~RenderDataIface() = default;