#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[] = …;
uint32_t g_sandbox_policy = …;
UNSUPPORT_INFO* g_unsupport_info = …;
bool RaiseUnsupportedError(int nError) { … }
bool DocHasXFA(const CPDF_Document* doc) { … }
unsigned long GetStreamMaybeCopyAndReturnLengthImpl(
RetainPtr<const CPDF_Stream> stream,
pdfium::span<uint8_t> buffer,
bool decode) { … }
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
}
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
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) { … }