summaryrefslogtreecommitdiff
path: root/svx/source/svdraw
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-07-06 14:08:23 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-08-01 08:30:27 +0200
commit7cbb10598d6b1a0f5e0d612eb6ffc1df28d086e4 (patch)
treeb9caba4afb341cd71f505716d27f8997af68a466 /svx/source/svdraw
parent7e02d0e4f22aa362184a5ac634eb916383f3f3d5 (diff)
pdf: add PDFiumPathSegment to the wrapper & use in ImpSdrPdfImport
A PageObject of type FPDF_PAGEOBJ_PATH can have a path segment, that is common in vector graphic objects. The path segment is wrapped into PDFiumPathSegment which can be used to handle the path and path properties. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98210 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit bc8016b81c2c609711c26af1f85da327cf30a4ff) Change-Id: I990d51ba90fa356a6eca137eb4b71947858289aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99879 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r--svx/source/svdraw/svdpdf.cxx43
1 files changed, 18 insertions, 25 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index ff4029a00b54..62bebbf4ce3b 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -697,10 +697,10 @@ void ImpSdrPdfImport::ImportPdfObject(
ImportText(pPageObject, pTextPage, nPageObjectIndex);
break;
case FPDF_PAGEOBJ_PATH:
- ImportPath(pPageObject->getPointer(), nPageObjectIndex);
+ ImportPath(pPageObject, nPageObjectIndex);
break;
case FPDF_PAGEOBJ_IMAGE:
- ImportImage(pPageObject->getPointer(), nPageObjectIndex);
+ ImportImage(pPageObject, nPageObjectIndex);
break;
case FPDF_PAGEOBJ_SHADING:
SAL_WARN("sd.filter", "Got page object SHADING: " << nPageObjectIndex);
@@ -893,10 +893,11 @@ void ImpSdrPdfImport::MapScaling()
mnMapScalingOfs = nCount;
}
-void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
+void ImpSdrPdfImport::ImportImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
+ int /*nPageObjectIndex*/)
{
std::unique_ptr<std::remove_pointer<FPDF_BITMAP>::type, FPDFBitmapDeleter> bitmap(
- FPDFImageObj_GetBitmap(pPageObject));
+ FPDFImageObj_GetBitmap(pPageObject->getPointer()));
if (!bitmap)
{
SAL_WARN("sd.filter", "Failed to get IMAGE");
@@ -939,7 +940,7 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObject
float bottom;
float right;
float top;
- if (!FPDFPageObj_GetBounds(pPageObject, &left, &bottom, &right, &top))
+ if (!FPDFPageObj_GetBounds(pPageObject->getPointer(), &left, &bottom, &right, &top))
{
SAL_WARN("sd.filter", "FAILED to get image bounds");
}
@@ -956,34 +957,26 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObject
InsertObj(pGraf);
}
-void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
+void ImpSdrPdfImport::ImportPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
+ int /*nPageObjectIndex*/)
{
- double a, b, c, d, e, f;
- FPDFPath_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- auto aPathMatrix = basegfx::B2DHomMatrix::abcdef(a, b, c, d, e, f);
+ auto aPathMatrix = pPageObject->getMatrix();
aPathMatrix *= maCurrentMatrix;
basegfx::B2DPolyPolygon aPolyPoly;
basegfx::B2DPolygon aPoly;
std::vector<basegfx::B2DPoint> aBezier;
- const int nSegments = FPDFPath_CountSegments(pPageObject);
+ const int nSegments = pPageObject->getPathSegmentCount();
for (int nSegmentIndex = 0; nSegmentIndex < nSegments; ++nSegmentIndex)
{
- FPDF_PATHSEGMENT pPathSegment = FPDFPath_GetPathSegment(pPageObject, nSegmentIndex);
+ auto pPathSegment = pPageObject->getPathSegment(nSegmentIndex);
if (pPathSegment != nullptr)
{
- float fx, fy;
- if (!FPDFPathSegment_GetPoint(pPathSegment, &fx, &fy))
- {
- SAL_WARN("sd.filter", "Failed to get PDF path segment point");
- continue;
- }
-
- basegfx::B2DPoint aB2DPoint(fx, fy);
+ basegfx::B2DPoint aB2DPoint = pPathSegment->getPoint();
aB2DPoint *= aPathMatrix;
- const bool bClose = FPDFPathSegment_GetClose(pPathSegment);
+ const bool bClose = pPathSegment->isClosed();
if (bClose)
aPoly.setClosed(bClose); // TODO: Review
@@ -991,7 +984,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI
aB2DPoint.setX(aPoint.X());
aB2DPoint.setY(aPoint.Y());
- const int nSegmentType = FPDFPathSegment_GetType(pPathSegment);
+ const int nSegmentType = pPathSegment->getType();
switch (nSegmentType)
{
case FPDF_SEGMENT_LINETO:
@@ -1043,13 +1036,13 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI
aPolyPoly.transform(aTransform);
float fWidth = 1;
- FPDFPageObj_GetStrokeWidth(pPageObject, &fWidth);
+ FPDFPageObj_GetStrokeWidth(pPageObject->getPointer(), &fWidth);
const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * fWidth);
mnLineWidth = convertPointToMm100(dWidth);
int nFillMode = FPDF_FILLMODE_ALTERNATE;
FPDF_BOOL bStroke = 1; // Assume we have to draw, unless told otherwise.
- if (FPDFPath_GetDrawMode(pPageObject, &nFillMode, &bStroke))
+ if (FPDFPath_GetDrawMode(pPageObject->getPointer(), &nFillMode, &bStroke))
{
if (nFillMode == FPDF_FILLMODE_ALTERNATE)
mpVD->SetDrawMode(DrawModeFlags::Default);
@@ -1063,12 +1056,12 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI
unsigned int nG;
unsigned int nB;
unsigned int nA;
- FPDFPageObj_GetFillColor(pPageObject, &nR, &nG, &nB, &nA);
+ FPDFPageObj_GetFillColor(pPageObject->getPointer(), &nR, &nG, &nB, &nA);
mpVD->SetFillColor(Color(nR, nG, nB));
if (bStroke)
{
- FPDFPageObj_GetStrokeColor(pPageObject, &nR, &nG, &nB, &nA);
+ FPDFPageObj_GetStrokeColor(pPageObject->getPointer(), &nR, &nG, &nB, &nA);
mpVD->SetLineColor(Color(nR, nG, nB));
}
else