From 397aa7177e23d848ae7db5e8db32fd05da838660 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sun, 22 Apr 2018 17:21:30 -0400 Subject: svx: support no fill and no stroke paths in PDF import Change-Id: Ida5daa71d469805fd52e08e804fb9fa182d7d008 (cherry picked from commit e25ed0d0690ee8d5f07c98ccbb79868415fef5fb) --- svx/source/svdraw/svdpdf.cxx | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 4b5d6af2d449..90d2ba45ed54 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -1417,11 +1417,24 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd float fWidth = 1; FPDFPath_GetStrokeWidth(pPageObject, &fWidth); - SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth); - const double dWidth = fabs(sqrt2(a, c) * fWidth); - SAL_WARN("sd.filter", "Path Stroke Width scaled: " << dWidth); + const double dWidth = 0.5 * fabs(sqrt2(mCurMatrix.a(), mCurMatrix.c()) * fWidth); mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth)); mnLineWidth /= 2; + SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth << ", scaled: " << dWidth + << ", Logical: " << mnLineWidth); + + int nFillMode = FPDF_FILLMODE_ALTERNATE; + FPDF_BOOL bStroke = true; + if (FPDFPath_GetDrawMode(pPageObject, &nFillMode, &bStroke)) + { + SAL_WARN("sd.filter", "Got PATH FillMode: " << nFillMode << ", Storke: " << bStroke); + if (nFillMode == FPDF_FILLMODE_ALTERNATE) + mpVD->SetDrawMode(DrawModeFlags::Default); + else if (nFillMode == FPDF_FILLMODE_WINDING) + mpVD->SetDrawMode(DrawModeFlags::Default); + else + mpVD->SetDrawMode(DrawModeFlags::NoFill); + } unsigned int nR; unsigned int nG; @@ -1431,15 +1444,15 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd SAL_WARN("sd.filter", "Got PATH fill color: " << nR << ", " << nG << ", " << nB << ", " << nA); mpVD->SetFillColor(Color(nR, nG, nB)); - FPDFPath_GetStrokeColor(pPageObject, &nR, &nG, &nB, &nA); - SAL_WARN("sd.filter", - "Got PATH stroke color: " << nR << ", " << nG << ", " << nB << ", " << nA); - mpVD->SetLineColor(Color(nR, nG, nB)); - - // int nFillMode = 0; // No fill. - // bool bStroke = false; - // FPDFPath_GetDrawMode(pPageObject, &nFillMode, &bStroke); - // mpVD->Setstroke(Color(r, g, b)); + if (bStroke) + { + FPDFPath_GetStrokeColor(pPageObject, &nR, &nG, &nB, &nA); + SAL_WARN("sd.filter", + "Got PATH stroke color: " << nR << ", " << nG << ", " << nB << ", " << nA); + mpVD->SetLineColor(Color(nR, nG, nB)); + } + else + mpVD->SetLineColor(COL_TRANSPARENT); // if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource))) -- cgit v1.2.3