From 51fc36477e4d955470fd407f43151b9727fd8b02 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Tue, 5 Jun 2018 11:31:05 +0200 Subject: [PATCH 06/14] svx: improve path importing from PDF --- pdfium/fpdfsdk/fpdf_editpath.cpp | 43 ++++++++++++++++++++++++++++++++++++++++ pdfium/public/fpdf_edit.h | 30 ++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/pdfium/fpdfsdk/fpdf_editpath.cpp b/pdfium/fpdfsdk/fpdf_editpath.cpp index 55f9fce..f41db64 100644 --- a/pdfium/fpdfsdk/fpdf_editpath.cpp +++ b/pdfium/fpdfsdk/fpdf_editpath.cpp @@ -245,6 +245,25 @@ 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 = 0; // no fill + + *stroke = pPathObj->m_bStroke; + return true; +} + FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT path, int line_join) { if (!path) @@ -277,6 +296,30 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT path, pPathObj->SetDirty(true); } +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPath_GetMatrix(FPDF_PAGEOBJECT path_object, + double* a, + double* b, + double* c, + double* d, + double* e, + double* f) +{ + if (!path_object || !a || !b || !c || !d || !e || !f) + return false; + + auto* pPathObj = CPDFPageObjectFromFPDFPageObject(path_object); + CFX_Matrix* pMatrix = pPathObj->m_GeneralState.GetMutableMatrix(); + *a = pMatrix->a; + *b = pMatrix->b; + *c = pMatrix->c; + *d = pMatrix->d; + *e = pMatrix->e; + *f = pMatrix->f; + + return true; +} + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y) { auto* pPathPoint = FXPathPointFromFPDFPathSegment(segment); diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h index b44bc71..89ec8cf 100644 --- a/pdfium/public/fpdf_edit.h +++ b/pdfium/public/fpdf_edit.h @@ -907,6 +907,36 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, int fillmode, FPDF_BOOL stroke); +// Get 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. +// stroke - a boolean specifying if the path should be stroked or not. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path, + int* fillmode, + FPDF_BOOL* stroke); + +// Get the matrix of a particular text object. +// +// path_object - Handle of path object returned by FPDFPath_NewPathObj +// a - Pointer to a double value receiving coefficient "a" of the matrix. +// b - Pointer to a double value receiving coefficient "b" of the matrix. +// c - Pointer to a double value receiving coefficient "c" of the matrix. +// d - Pointer to a double value receiving coefficient "d" of the matrix. +// e - Pointer to a double value receiving coefficient "e" of the matrix. +// f - Pointer to a double value receiving coefficient "f" of the matrix. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPath_GetMatrix(FPDF_PAGEOBJECT path_object, + double* a, + double* b, + double* c, + double* d, + double* e, + double* f); + // Create a new text object using one of the standard PDF fonts. // // document - handle to the document. -- 2.16.3