chromium/third_party/pdfium/fpdfsdk/cpdfsdk_helpers.cpp

// Copyright 2018 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 "fpdfsdk/cpdfsdk_helpers.h"

#include <utility>

#include "build/build_config.h"
#include "constants/form_fields.h"
#include "constants/stream_dict_common.h"
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fpdfdoc/cpdf_annot.h"
#include "core/fpdfdoc/cpdf_interactiveform.h"
#include "core/fpdfdoc/cpdf_metadata.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/fx_memcpy_wrappers.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/numerics/safe_conversions.h"
#include "core/fxcrt/span_util.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxcrt/unowned_ptr.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"

namespace {

constexpr char kQuadPoints[] =;

// 0 bit: FPDF_POLICY_MACHINETIME_ACCESS
uint32_t g_sandbox_policy =;

UNSUPPORT_INFO* g_unsupport_info =;

bool RaiseUnsupportedError(int nError) {}

// Use the existence of the XFA array as a signal for XFA forms.
bool DocHasXFA(const CPDF_Document* doc) {}

unsigned long GetStreamMaybeCopyAndReturnLengthImpl(
    RetainPtr<const CPDF_Stream> stream,
    pdfium::span<uint8_t> buffer,
    bool decode) {}

// TODO(tsepez): should be UNSAFE_BUFFER_USAGE.
size_t FPDFWideStringLength(const unsigned short* str) {}

#ifdef PDF_ENABLE_XFA
class FPDF_FileHandlerContext final : public IFX_SeekableStream {};

FPDF_FileHandlerContext::FPDF_FileHandlerContext(FPDF_FILEHANDLER* pFS)
    :{}

FPDF_FileHandlerContext::~FPDF_FileHandlerContext() {}

FX_FILESIZE FPDF_FileHandlerContext::GetSize() {}

bool FPDF_FileHandlerContext::IsEOF() {}

FX_FILESIZE FPDF_FileHandlerContext::GetPosition() {}

bool FPDF_FileHandlerContext::ReadBlockAtOffset(pdfium::span<uint8_t> buffer,
                                                FX_FILESIZE offset) {}

bool FPDF_FileHandlerContext::WriteBlock(pdfium::span<const uint8_t> buffer) {}

bool FPDF_FileHandlerContext::Flush() {}
#endif  // PDF_ENABLE_XFA

}  // namespace

IPDF_Page* IPDFPageFromFPDFPage(FPDF_PAGE page) {}

FPDF_PAGE FPDFPageFromIPDFPage(IPDF_Page* page) {}

CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) {}

FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) {}

CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {}

FXDIB_Format FXDIBFormatFromFPDFFormat(int format) {}

CPDFSDK_InteractiveForm* FormHandleToInteractiveForm(FPDF_FORMHANDLE hHandle) {}

ByteString ByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string) {}

WideString WideStringFromFPDFWideString(FPDF_WIDESTRING wide_string) {}

UNSAFE_BUFFER_USAGE pdfium::span<char> SpanFromFPDFApiArgs(
    void* buffer,
    pdfium::StrictNumeric<size_t> buflen) {}

#ifdef PDF_ENABLE_XFA
RetainPtr<IFX_SeekableStream> MakeSeekableStream(
    FPDF_FILEHANDLER* pFilehandler) {}
#endif  // PDF_ENABLE_XFA

RetainPtr<const CPDF_Array> GetQuadPointsArrayFromDictionary(
    const CPDF_Dictionary* dict) {}

RetainPtr<CPDF_Array> GetMutableQuadPointsArrayFromDictionary(
    CPDF_Dictionary* dict) {}

RetainPtr<CPDF_Array> AddQuadPointsArrayToDictionary(CPDF_Dictionary* dict) {}

bool IsValidQuadPointsIndex(const CPDF_Array* array, size_t index) {}

bool GetQuadPointsAtIndex(RetainPtr<const CPDF_Array> array,
                          size_t quad_index,
                          FS_QUADPOINTSF* quad_points) {}

CFX_PointF CFXPointFFromFSPointF(const FS_POINTF& point) {}

CFX_FloatRect CFXFloatRectFromFSRectF(const FS_RECTF& rect) {}

FS_RECTF FSRectFFromCFXFloatRect(const CFX_FloatRect& rect) {}

CFX_Matrix CFXMatrixFromFSMatrix(const FS_MATRIX& matrix) {}

FS_MATRIX FSMatrixFromCFXMatrix(const CFX_Matrix& matrix) {}

unsigned long NulTerminateMaybeCopyAndReturnLength(
    const ByteString& text,
    pdfium::span<char> result_span) {}

unsigned long Utf16EncodeMaybeCopyAndReturnLength(
    const WideString& text,
    pdfium::span<char> result_span) {}

unsigned long GetRawStreamMaybeCopyAndReturnLength(
    RetainPtr<const CPDF_Stream> stream,
    pdfium::span<uint8_t> buffer) {}

unsigned long DecodeStreamMaybeCopyAndReturnLength(
    RetainPtr<const CPDF_Stream> stream,
    pdfium::span<uint8_t> buffer) {}

void SetPDFSandboxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) {}

FPDF_BOOL IsPDFSandboxPolicyEnabled(FPDF_DWORD policy) {}

void SetPDFUnsupportInfo(UNSUPPORT_INFO* unsp_info) {}

void ReportUnsupportedFeatures(const CPDF_Document* pDoc) {}

void ReportUnsupportedXFA(const CPDF_Document* pDoc) {}

void CheckForUnsupportedAnnot(const CPDF_Annot* pAnnot) {}

void ProcessParseError(CPDF_Parser::Error err) {}

void SetColorFromScheme(const FPDF_COLORSCHEME* pColorScheme,
                        CPDF_RenderOptions* pRenderOptions) {}

std::vector<uint32_t> ParsePageRangeString(const ByteString& bsPageRange,
                                           uint32_t nCount) {}