From 3285732ee73e97feb3fed4da6abc41b1c705ed30 Mon Sep 17 00:00:00 2001 Date: Wed, 30 May 2018 13:30:10 +0000 Subject: [PATCH] Add FPDFPath_GetDrawMode() API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was already possible to set the draw mode of a path object, this is the other direction. Change-Id: Id0ee98dd8dfe433edd0e4715fc009ad4d1625981 Reviewed-on: https://pdfium-review.googlesource.com/33010 Reviewed-by: dsinclair Reviewed-by: Nicolás Peña Moreno Commit-Queue: dsinclair --- fpdfsdk/fpdf_edit_embeddertest.cpp | 7 +++++++ fpdfsdk/fpdf_editpath.cpp | 18 ++++++++++++++++++ public/fpdf_edit.h | 16 ++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp index aca2bebf8..558a8e3de 100644 --- a/fpdfsdk/fpdf_editpath.cpp +++ b/fpdfsdk/fpdf_editpath.cpp @@ -235,6 +235,24 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, return true; } +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path, + int* fillmode, + FPDF_BOOL* stroke) { + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); + if (!pPathObj || !fillmode || !stroke) + return false; + + if (pPathObj->m_FillType == FXFILL_ALTERNATE) + *fillmode = FPDF_FILLMODE_ALTERNATE; + else if (pPathObj->m_FillType == FXFILL_WINDING) + *fillmode = FPDF_FILLMODE_WINDING; + else + *fillmode = FPDF_FILLMODE_NONE; + + *stroke = pPathObj->m_bStroke; + return true; +} + FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT path, int line_join) { if (!path) diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h index 49018df05..2faa9ecba 100644 --- a/public/fpdf_edit.h +++ b/public/fpdf_edit.h @@ -48,6 +48,7 @@ #define FPDF_SEGMENT_BEZIERTO 1 #define FPDF_SEGMENT_MOVETO 2 +#define FPDF_FILLMODE_NONE 0 #define FPDF_FILLMODE_ALTERNATE 1 #define FPDF_FILLMODE_WINDING 2 @@ -899,8 +900,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path); // Set the drawing mode of a path. // // path - the handle to the path object. -// fillmode - the filling mode to be set: 0 for no fill, 1 for alternate, 2 for -// winding. +// fillmode - the filling mode to be set: one of the FPDF_FILLMODE_* flags. // stroke - a boolean specifying if the path should be stroked or not. // // Returns TRUE on success @@ -908,6 +908,18 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, int fillmode, FPDF_BOOL stroke); +// Experimental API. +// Get the drawing mode of a path. +// +// path - the handle to the path object. +// fillmode - the filling mode of the path: one of the FPDF_FILLMODE_* flags. +// stroke - a boolean specifying if the path is stroked or not. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path, + int* fillmode, + FPDF_BOOL* stroke); + // Create a new text object using one of the standard PDF fonts. // // document - handle to the document. -- 2.16.4