5#include "public/fpdf_edit.h"
10#include "core/fpdfapi/page/cpdf_path.h"
11#include "core/fpdfapi/page/cpdf_pathobject.h"
12#include "core/fxcrt/fx_system.h"
13#include "core/fxcrt/stl_util.h"
14#include "fpdfsdk/cpdfsdk_helpers.h"
15#include "third_party/base/containers/span.h"
20 "CFX_GraphStateData::LineCap::kButt value mismatch");
23 "CFX_GraphStateData::LineCap::kRound value mismatch");
26 "CFX_GraphStateData::LineCap::kSquare value mismatch");
30 "CFX_GraphStateData::LineJoin::kMiter value mismatch");
33 "CFX_GraphStateData::LineJoin::kRound value mismatch");
36 "CFX_GraphStateData::LineJoin::kBevel value mismatch");
40 "CFX_Path::Point::Type::kLine value mismatch");
43 "CFX_Path::Point::Type::kBezier value mismatch");
46 "CFX_Path::Point::Type::kMove value mismatch");
50CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
59 auto pPathObj =
std::make_unique<CPDF_PathObject>();
61 pPathObj->SetDefaultStates();
64 return FPDFPageObjectFromCPDFPageObject(pPathObj.release());
71 auto pPathObj =
std::make_unique<CPDF_PathObject>();
72 pPathObj->path().AppendRect(x, y, x + w, y + h);
73 pPathObj->SetDefaultStates();
76 return FPDFPageObjectFromCPDFPageObject(pPathObj.release());
80 auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
83 return fxcrt::CollectionSize<
int>(pPathObj
->path().GetPoints());
88 auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
92 pdfium::span<
const CFX_Path::
Point> points = pPathObj->path().GetPoints();
93 if (!
fxcrt::IndexInBounds(points, index))
96 return FPDFPathSegmentFromFXPathPoint(&points[index]);
102 auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
114 auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
130 auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
143 auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
148 if (cpath.GetPoints().empty())
159 auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
177 auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
178 if (!pPathObj || !fillmode || !stroke)
195 if (!pPathPoint || !x || !y)
198 *x = pPathPoint->m_Point.x;
199 *y = pPathPoint->m_Point.y;
206 return pPathPoint ?
static_cast<
int>(pPathPoint
->m_Type)
void SetDirty(bool value)
virtual CPDF_PathObject * AsPath()
void set_alternate_filltype()
void set_winding_filltype()
bool has_winding_filltype() const
void set_stroke(bool stroke)
bool has_alternate_filltype() const
void AppendPoint(const CFX_PointF &point, CFX_Path::Point::Type type)
const CFX_Path::Point * FXPathPointFromFPDFPathSegment(FPDF_PATHSEGMENT segment)
CPDF_PageObject * CPDFPageObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object)
FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV FPDFPath_GetPathSegment(FPDF_PAGEOBJECT path, int index)
#define FPDF_LINECAP_BUTT
#define FPDF_FILLMODE_ALTERNATE
FPDF_EXPORT int FPDF_CALLCONV FPDFPathSegment_GetType(FPDF_PATHSEGMENT segment)
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x, float y)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, int fillmode, FPDF_BOOL stroke)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float *x, float *y)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path, int *fillmode, FPDF_BOOL *stroke)
#define FPDF_FILLMODE_NONE
#define FPDF_LINEJOIN_MITER
#define FPDF_LINEJOIN_ROUND
#define FPDF_SEGMENT_MOVETO
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewRect(float x, float y, float w, float h)
#define FPDF_LINECAP_PROJECTING_SQUARE
#define FPDF_LINECAP_ROUND
#define FPDF_SEGMENT_UNKNOWN
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path, float x, float y)
#define FPDF_SEGMENT_BEZIERTO
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_BezierTo(FPDF_PAGEOBJECT path, float x1, float y1, float x2, float y2, float x3, float y3)
FPDF_EXPORT int FPDF_CALLCONV FPDFPath_CountSegments(FPDF_PAGEOBJECT path)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_MoveTo(FPDF_PAGEOBJECT path, float x, float y)
#define FPDF_LINEJOIN_BEVEL
#define FPDF_SEGMENT_LINETO
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment)
#define FPDF_FILLMODE_WINDING