summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-12-01 21:02:54 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-12-02 09:07:51 +0100
commit0e072c8225e747267eeb915ac88b33b7201df210 (patch)
tree43bb7c642f61cdea9b17ab1558af7274ad0055c7 /vcl
parent4d7ad433c6ebd9fbcac480ebdd00af933a437df5 (diff)
pdfium: introduce an enum class for path segment types
Towards not including fpdf_edit.h in PDFiumLibrary client code. Change-Id: Iffdd11b0613399f31a3ed383c22b7a91059b83de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107011 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx10
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx14
2 files changed, 18 insertions, 6 deletions
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 136c54aec41e..eaf905986928 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -861,35 +861,35 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf108963)
CPPUNIT_ASSERT_EQUAL(5, nSegments);
std::unique_ptr<vcl::pdf::PDFiumPathSegment> pSegment
= pPdfPageObject->getPathSegment(0);
- CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_MOVETO, pSegment->getType());
+ CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Moveto, pSegment->getType());
basegfx::B2DPoint aPoint = pSegment->getPoint();
CPPUNIT_ASSERT_EQUAL(245395, static_cast<int>(round(aPoint.getX() * 1000)));
CPPUNIT_ASSERT_EQUAL(244261, static_cast<int>(round(aPoint.getY() * 1000)));
CPPUNIT_ASSERT(!pSegment->isClosed());
pSegment = pPdfPageObject->getPathSegment(1);
- CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, pSegment->getType());
+ CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, pSegment->getType());
aPoint = pSegment->getPoint();
CPPUNIT_ASSERT_EQUAL(275102, static_cast<int>(round(aPoint.getX() * 1000)));
CPPUNIT_ASSERT_EQUAL(267618, static_cast<int>(round(aPoint.getY() * 1000)));
CPPUNIT_ASSERT(!pSegment->isClosed());
pSegment = pPdfPageObject->getPathSegment(2);
- CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, pSegment->getType());
+ CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, pSegment->getType());
aPoint = pSegment->getPoint();
CPPUNIT_ASSERT_EQUAL(287518, static_cast<int>(round(aPoint.getX() * 1000)));
CPPUNIT_ASSERT_EQUAL(251829, static_cast<int>(round(aPoint.getY() * 1000)));
CPPUNIT_ASSERT(!pSegment->isClosed());
pSegment = pPdfPageObject->getPathSegment(3);
- CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, pSegment->getType());
+ CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, pSegment->getType());
aPoint = pSegment->getPoint();
CPPUNIT_ASSERT_EQUAL(257839, static_cast<int>(round(aPoint.getX() * 1000)));
CPPUNIT_ASSERT_EQUAL(228472, static_cast<int>(round(aPoint.getY() * 1000)));
CPPUNIT_ASSERT(!pSegment->isClosed());
pSegment = pPdfPageObject->getPathSegment(4);
- CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, pSegment->getType());
+ CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, pSegment->getType());
aPoint = pSegment->getPoint();
CPPUNIT_ASSERT_EQUAL(245395, static_cast<int>(round(aPoint.getX() * 1000)));
CPPUNIT_ASSERT_EQUAL(244261, static_cast<int>(round(aPoint.getY() * 1000)));
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 5c308d3e772b..0952c9a5d3e8 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -42,6 +42,15 @@ static_assert(static_cast<int>(vcl::pdf::PDFPageObjectType::Shading) == FPDF_PAG
static_assert(static_cast<int>(vcl::pdf::PDFPageObjectType::Form) == FPDF_PAGEOBJ_FORM,
"PDFPageObjectType::Form value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFSegmentType::Unknown) == FPDF_SEGMENT_UNKNOWN,
+ "PDFSegmentType::Unknown value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFSegmentType::Lineto) == FPDF_SEGMENT_LINETO,
+ "PDFSegmentType::Lineto value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFSegmentType::Bezierto) == FPDF_SEGMENT_BEZIERTO,
+ "PDFSegmentType::Bezierto value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFSegmentType::Moveto) == FPDF_SEGMENT_MOVETO,
+ "PDFSegmentType::Moveto value mismatch");
+
namespace
{
/// Callback class to be used with FPDF_SaveWithVersion().
@@ -604,7 +613,10 @@ basegfx::B2DPoint PDFiumPathSegment::getPoint() const
bool PDFiumPathSegment::isClosed() const { return FPDFPathSegment_GetClose(mpPathSegment); }
-int PDFiumPathSegment::getType() const { return FPDFPathSegment_GetType(mpPathSegment); }
+PDFSegmentType PDFiumPathSegment::getType() const
+{
+ return static_cast<PDFSegmentType>(FPDFPathSegment_GetType(mpPathSegment));
+}
PDFiumBitmap::PDFiumBitmap(FPDF_BITMAP pBitmap)
: mpBitmap(pBitmap)