7#ifndef FPDFSDK_CPDFSDK_HELPERS_H_
8#define FPDFSDK_CPDFSDK_HELPERS_H_
12#include "build/build_config.h"
13#include "core/fpdfapi/page/cpdf_page.h"
14#include "core/fpdfapi/parser/cpdf_parser.h"
15#include "core/fxcrt/retain_ptr.h"
16#include "core/fxge/cfx_path.h"
17#include "public/fpdf_doc.h"
18#include "public/fpdf_ext.h"
19#include "public/fpdfview.h"
22#include "core/fxcrt/fx_stream.h"
28class CPDF_ContentMarkItem;
35class CPDF_StructElement;
39class CPDFSDK_FormFillEnvironment;
40class CPDFSDK_InteractiveForm;
54 return reinterpret_cast<FPDF_ACTION>(
const_cast<CPDF_Dictionary*>(action));
57 return reinterpret_cast<CPDF_Dictionary*>(action);
62 return reinterpret_cast<FPDF_ANNOTATION>(annot);
65 FPDF_ANNOTATION annot) {
70 return reinterpret_cast<FPDF_ATTACHMENT>(attachment);
77 return reinterpret_cast<FPDF_BITMAP>(bitmap);
80 return reinterpret_cast<CFX_DIBitmap*>(bitmap);
84 const CPDF_Dictionary* bookmark) {
85 return reinterpret_cast<FPDF_BOOKMARK>(
86 const_cast<CPDF_Dictionary*>(bookmark));
89 return reinterpret_cast<CPDF_Dictionary*>(bookmark);
93 return reinterpret_cast<FPDF_CLIPPATH>(path);
100 return reinterpret_cast<FPDF_DEST>(
const_cast<CPDF_Array*>(dest));
103 return reinterpret_cast<CPDF_Array*>(dest);
107 return reinterpret_cast<FPDF_FONT>(font);
110 return reinterpret_cast<
CPDF_Font*>(font);
115 return reinterpret_cast<FPDF_JAVASCRIPT_ACTION>(javascript);
118 FPDF_JAVASCRIPT_ACTION javascript) {
123 return reinterpret_cast<FPDF_LINK>(link);
126 return reinterpret_cast<CPDF_Dictionary*>(link);
130 return reinterpret_cast<FPDF_PAGELINK>(link);
138 return reinterpret_cast<FPDF_PAGEOBJECT>(page_object);
141 FPDF_PAGEOBJECT page_object) {
146 CPDF_ContentMarkItem* mark) {
147 return reinterpret_cast<FPDF_PAGEOBJECTMARK>(mark);
150 FPDF_PAGEOBJECTMARK mark) {
151 return reinterpret_cast<CPDF_ContentMarkItem*>(mark);
155 return reinterpret_cast<FPDF_PAGERANGE>(range);
158 return reinterpret_cast<
const CPDF_Array*>(range);
163 return reinterpret_cast<FPDF_PATHSEGMENT>(segment);
166 FPDF_PATHSEGMENT segment) {
172 return reinterpret_cast<FPDF_STRUCTTREE>(struct_tree);
175 FPDF_STRUCTTREE struct_tree) {
180 CPDF_StructElement* struct_element) {
181 return reinterpret_cast<FPDF_STRUCTELEMENT>(struct_element);
184 FPDF_STRUCTELEMENT struct_element) {
185 return reinterpret_cast<CPDF_StructElement*>(struct_element);
189 const CPDF_Dictionary* dictionary) {
190 return reinterpret_cast<FPDF_STRUCTELEMENT_ATTR>(dictionary);
193 FPDF_STRUCTELEMENT_ATTR struct_element_attr) {
194 return reinterpret_cast<
const CPDF_Dictionary*>(struct_element_attr);
198 return reinterpret_cast<FPDF_TEXTPAGE>(page);
206 return reinterpret_cast<FPDF_SCHHANDLE>(handle);
209 FPDF_SCHHANDLE handle) {
214 CPDFSDK_FormFillEnvironment* handle) {
215 return reinterpret_cast<FPDF_FORMHANDLE>(handle);
217inline CPDFSDK_FormFillEnvironment*
219 return reinterpret_cast<CPDFSDK_FormFillEnvironment*>(handle);
223 const CPDF_Dictionary* dictionary) {
224 return reinterpret_cast<FPDF_SIGNATURE>(dictionary);
227 FPDF_SIGNATURE signature) {
228 return reinterpret_cast<
const CPDF_Dictionary*>(signature);
232 return reinterpret_cast<FPDF_XOBJECT>(xobject);
247RetainPtr<IFX_SeekableStream> MakeSeekableStream(
248 FPDF_FILEHANDLER* pFileHandler);
252 const CPDF_Dictionary* dict);
254 CPDF_Dictionary* dict);
259 FS_QUADPOINTSF* quad_points);
271 unsigned long buflen);
275 unsigned long buflen);
283 pdfium::span<uint8_t> buffer);
291 pdfium::span<uint8_t> buffer);
static bool UseSkiaRenderer()
void LoadSubst(const ByteString &face_name, bool bTrueType, uint32_t flags, int weight, int italic_angle, FX_CodePage code_page, bool bVertical)
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void Translate(int32_t x, int32_t y)
void AppendRect(float left, float bottom, float right, float top)
bool DrawDeviceText(pdfium::span< const TextCharPos > pCharPos, CFX_Font *pFont, const CFX_Matrix &mtObject2Device, float font_size, uint32_t color, const CFX_TextRenderOptions &options) override
void SaveState() override
bool SetClip_PathFill(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_FillRenderOptions &fill_options) override
void RestoreState(bool bKeepSaved) override
bool DrawPath(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_GraphStateData *pGraphState, uint32_t fill_color, uint32_t stroke_color, const CFX_FillRenderOptions &fill_options, BlendMode blend_type) override
RenderContextClearer(CPDF_Page *pPage)
const CPDF_Array * CPDFArrayFromFPDFPageRange(FPDF_PAGERANGE range)
WideString WideStringFromFPDFWideString(FPDF_WIDESTRING wide_string)
bool IsValidQuadPointsIndex(const CPDF_Array *array, size_t index)
FPDF_STRUCTTREE FPDFStructTreeFromCPDFStructTree(CPDF_StructTree *struct_tree)
std::vector< uint32_t > ParsePageRangeString(const ByteString &bsPageRange, uint32_t nCount)
FPDF_STRUCTELEMENT_ATTR FPDFStructElementAttrFromCPDFDictionary(const CPDF_Dictionary *dictionary)
unsigned long NulTerminateMaybeCopyAndReturnLength(const ByteString &text, void *buffer, unsigned long buflen)
ByteString ByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string)
FPDF_XOBJECT FPDFXObjectFromXObjectContext(XObjectContext *xobject)
CPDF_StructElement * CPDFStructElementFromFPDFStructElement(FPDF_STRUCTELEMENT struct_element)
FPDF_PAGELINK FPDFPageLinkFromCPDFLinkExtract(CPDF_LinkExtract *link)
FPDF_DEST FPDFDestFromCPDFArray(const CPDF_Array *dest)
IPDF_Page * IPDFPageFromFPDFPage(FPDF_PAGE page)
const CFX_Path::Point * FXPathPointFromFPDFPathSegment(FPDF_PATHSEGMENT segment)
CPDF_TextPageFind * CPDFTextPageFindFromFPDFSchHandle(FPDF_SCHHANDLE handle)
FPDF_JAVASCRIPT_ACTION FPDFJavaScriptActionFromCPDFJavaScriptAction(CPDF_JavaScript *javascript)
FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document *doc)
void ProcessParseError(CPDF_Parser::Error err)
XObjectContext * XObjectContextFromFPDFXObject(FPDF_XOBJECT xobject)
RetainPtr< CPDF_Array > AddQuadPointsArrayToDictionary(CPDF_Dictionary *dict)
CPDF_Array * CPDFArrayFromFPDFDest(FPDF_DEST dest)
unsigned long Utf16EncodeMaybeCopyAndReturnLength(const WideString &text, void *buffer, unsigned long buflen)
FPDF_SCHHANDLE FPDFSchHandleFromCPDFTextPageFind(CPDF_TextPageFind *handle)
FPDF_BITMAP FPDFBitmapFromCFXDIBitmap(CFX_DIBitmap *bitmap)
CFX_DIBitmap * CFXDIBitmapFromFPDFBitmap(FPDF_BITMAP bitmap)
FPDF_BOOL IsPDFSandboxPolicyEnabled(FPDF_DWORD policy)
CPDFSDK_FormFillEnvironment * CPDFSDKFormFillEnvironmentFromFPDFFormHandle(FPDF_FORMHANDLE handle)
FPDF_ANNOTATION FPDFAnnotationFromCPDFAnnotContext(CPDF_AnnotContext *annot)
FPDF_ACTION FPDFActionFromCPDFDictionary(const CPDF_Dictionary *action)
void SetPDFSandboxPolicy(FPDF_DWORD policy, FPDF_BOOL enable)
CPDF_Dictionary * CPDFDictionaryFromFPDFBookmark(FPDF_BOOKMARK bookmark)
CPDF_ContentMarkItem * CPDFContentMarkItemFromFPDFPageObjectMark(FPDF_PAGEOBJECTMARK mark)
CPDF_Object * CPDFObjectFromFPDFAttachment(FPDF_ATTACHMENT attachment)
RetainPtr< const CPDF_Array > GetQuadPointsArrayFromDictionary(const CPDF_Dictionary *dict)
FPDF_LINK FPDFLinkFromCPDFDictionary(CPDF_Dictionary *link)
const CPDF_Dictionary * CPDFDictionaryFromFPDFSignature(FPDF_SIGNATURE signature)
CPDF_AnnotContext * CPDFAnnotContextFromFPDFAnnotation(FPDF_ANNOTATION annot)
FPDF_PAGEOBJECT FPDFPageObjectFromCPDFPageObject(CPDF_PageObject *page_object)
bool GetQuadPointsAtIndex(RetainPtr< const CPDF_Array > array, size_t quad_index, FS_QUADPOINTSF *quad_points)
FPDF_PAGEOBJECTMARK FPDFPageObjectMarkFromCPDFContentMarkItem(CPDF_ContentMarkItem *mark)
FPDF_STRUCTELEMENT FPDFStructElementFromCPDFStructElement(CPDF_StructElement *struct_element)
CPDF_TextPage * CPDFTextPageFromFPDFTextPage(FPDF_TEXTPAGE page)
void ReportUnsupportedXFA(const CPDF_Document *pDoc)
FPDF_FONT FPDFFontFromCPDFFont(CPDF_Font *font)
CPDF_Font * CPDFFontFromFPDFFont(FPDF_FONT font)
FS_RECTF FSRectFFromCFXFloatRect(const CFX_FloatRect &rect)
RetainPtr< CPDF_Array > GetMutableQuadPointsArrayFromDictionary(CPDF_Dictionary *dict)
CPDF_Dictionary * CPDFDictionaryFromFPDFLink(FPDF_LINK link)
void CheckForUnsupportedAnnot(const CPDF_Annot *pAnnot)
void ReportUnsupportedFeatures(const CPDF_Document *pDoc)
CPDF_ClipPath * CPDFClipPathFromFPDFClipPath(FPDF_CLIPPATH path)
FS_MATRIX FSMatrixFromCFXMatrix(const CFX_Matrix &matrix)
FPDF_PATHSEGMENT FPDFPathSegmentFromFXPathPoint(const CFX_Path::Point *segment)
void SetColorFromScheme(const FPDF_COLORSCHEME *pColorScheme, CPDF_RenderOptions *pRenderOptions)
CFX_FloatRect CFXFloatRectFromFSRectF(const FS_RECTF &rect)
FPDF_PAGE FPDFPageFromIPDFPage(IPDF_Page *page)
unsigned long GetRawStreamMaybeCopyAndReturnLength(RetainPtr< const CPDF_Stream > stream, pdfium::span< uint8_t > buffer)
CPDF_JavaScript * CPDFJavaScriptActionFromFPDFJavaScriptAction(FPDF_JAVASCRIPT_ACTION javascript)
FPDF_CLIPPATH FPDFClipPathFromCPDFClipPath(CPDF_ClipPath *path)
CFX_PointF CFXPointFFromFSPointF(const FS_POINTF &point)
CPDF_Page * CPDFPageFromFPDFPage(FPDF_PAGE page)
CPDF_Document * CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc)
FPDF_BOOKMARK FPDFBookmarkFromCPDFDictionary(const CPDF_Dictionary *bookmark)
FPDF_SIGNATURE FPDFSignatureFromCPDFDictionary(const CPDF_Dictionary *dictionary)
CPDF_StructTree * CPDFStructTreeFromFPDFStructTree(FPDF_STRUCTTREE struct_tree)
unsigned long DecodeStreamMaybeCopyAndReturnLength(RetainPtr< const CPDF_Stream > stream, pdfium::span< uint8_t > buffer)
FPDF_TEXTPAGE FPDFTextPageFromCPDFTextPage(CPDF_TextPage *page)
FPDF_PAGERANGE FPDFPageRangeFromCPDFArray(const CPDF_Array *range)
const CPDF_Dictionary * CPDFDictionaryFromFPDFStructElementAttr(FPDF_STRUCTELEMENT_ATTR struct_element_attr)
void SetPDFUnsupportInfo(UNSUPPORT_INFO *unsp_info)
CPDF_PageObject * CPDFPageObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object)
CPDF_Dictionary * CPDFDictionaryFromFPDFAction(FPDF_ACTION action)
FPDF_FORMHANDLE FPDFFormHandleFromCPDFSDKFormFillEnvironment(CPDFSDK_FormFillEnvironment *handle)
CFX_Matrix CFXMatrixFromFSMatrix(const FS_MATRIX &matrix)
CPDFSDK_InteractiveForm * FormHandleToInteractiveForm(FPDF_FORMHANDLE hHandle)
CPDF_LinkExtract * CPDFLinkExtractFromFPDFPageLink(FPDF_PAGELINK link)
FPDF_ATTACHMENT FPDFAttachmentFromCPDFObject(CPDF_Object *attachment)
void CPDFSDK_RenderPageWithContext(CPDF_PageRenderContext *pContext, CPDF_Page *pPage, int start_x, int start_y, int size_x, int size_y, int rotate, int flags, const FPDF_COLORSCHEME *color_scheme, bool need_to_restore, CPDFSDK_PauseAdapter *pause)
TEST_F(FPDFParserDecodeEmbedderTest, Bug552046)
TEST(FXCRYPT, CryptToBase16)
constexpr CFX_FillRenderOptions()
static constexpr CFX_FillRenderOptions WindingOptions()
constexpr CFX_TextRenderOptions(AliasingType type)