summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-01-07 22:19:59 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-01-08 08:33:52 +0100
commitf6d2419188755f280afe7f30178c4b48de6993f3 (patch)
treea2e0a8327a1c38243259da50e2188e0ef0ed2d18
parentc8d564094ecb6e82ed924217651a8f88ce5039c8 (diff)
pdfium: add wrapper for FPDF_TEXTRENDERMODE_* defines
Change-Id: I85fe128f0b86d1e308727f7cc0f803d62c6ba48d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108952 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--include/vcl/filter/PDFiumLibrary.hxx3
-rw-r--r--include/vcl/pdf/PDFTextRenderMode.hxx30
-rw-r--r--svx/source/svdraw/svdpdf.cxx18
-rw-r--r--vcl/qa/cppunit/PDFiumLibraryTest.cxx2
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx29
5 files changed, 70 insertions, 12 deletions
diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx
index e32466b9bf13..aff5ad6ad8af 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -34,6 +34,7 @@
#include <vcl/pdf/PDFSegmentType.hxx>
#include <vcl/pdf/PDFBitmapType.hxx>
#include <vcl/pdf/PDFObjectType.hxx>
+#include <vcl/pdf/PDFTextRenderMode.hxx>
#include <fpdf_doc.h>
@@ -144,7 +145,7 @@ public:
basegfx::B2DRectangle getBounds();
double getFontSize();
OUString getFontName();
- int getTextRenderMode();
+ PDFTextRenderMode getTextRenderMode();
Color getFillColor();
Color getStrokeColor();
// Path
diff --git a/include/vcl/pdf/PDFTextRenderMode.hxx b/include/vcl/pdf/PDFTextRenderMode.hxx
new file mode 100644
index 000000000000..366a080fb79e
--- /dev/null
+++ b/include/vcl/pdf/PDFTextRenderMode.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+namespace vcl::pdf
+{
+enum class PDFTextRenderMode
+{
+ Unknown = -1,
+ Fill = 0,
+ Stroke = 1,
+ FillStroke = 2,
+ Invisible = 3,
+ FillClip = 4,
+ StrokeClip = 5,
+ FillStrokeClip = 6,
+ Clip = 7
+};
+
+} // namespace vcl::pdf
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 847d75250739..ab75355fab04 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -758,18 +758,18 @@ void ImpSdrPdfImport::ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> con
bool bUse = true;
switch (pPageObject->getTextRenderMode())
{
- case FPDF_TEXTRENDERMODE_FILL:
- case FPDF_TEXTRENDERMODE_FILL_CLIP:
- case FPDF_TEXTRENDERMODE_FILL_STROKE:
- case FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP:
+ case vcl::pdf::PDFTextRenderMode::Fill:
+ case vcl::pdf::PDFTextRenderMode::FillClip:
+ case vcl::pdf::PDFTextRenderMode::FillStroke:
+ case vcl::pdf::PDFTextRenderMode::FillStrokeClip:
bFill = true;
break;
- case FPDF_TEXTRENDERMODE_STROKE:
- case FPDF_TEXTRENDERMODE_STROKE_CLIP:
- case FPDF_TEXTRENDERMODE_UNKNOWN:
+ case vcl::pdf::PDFTextRenderMode::Stroke:
+ case vcl::pdf::PDFTextRenderMode::StrokeClip:
+ case vcl::pdf::PDFTextRenderMode::Unknown:
break;
- case FPDF_TEXTRENDERMODE_INVISIBLE:
- case FPDF_TEXTRENDERMODE_CLIP:
+ case vcl::pdf::PDFTextRenderMode::Invisible:
+ case vcl::pdf::PDFTextRenderMode::Clip:
bUse = false;
break;
}
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index 88bbf9978da2..c2d55ce61b26 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -146,7 +146,7 @@ void PDFiumLibraryTest::testPageObjects()
CPPUNIT_ASSERT_EQUAL(12.0, pPageObject->getFontSize());
CPPUNIT_ASSERT_EQUAL(OUString("Liberation Serif"), pPageObject->getFontName());
- CPPUNIT_ASSERT_EQUAL(0, pPageObject->getTextRenderMode()); // FPDF_TEXTRENDERMODE_FILL
+ CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFTextRenderMode::Fill, pPageObject->getTextRenderMode());
CPPUNIT_ASSERT_EQUAL(COL_BLACK, pPageObject->getFillColor());
CPPUNIT_ASSERT_EQUAL(COL_BLACK, pPageObject->getStrokeColor());
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index dbae22b07bdc..3165f669f41d 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -83,6 +83,30 @@ static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Nullobj) == FPDF_OBJECT_
static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Reference) == FPDF_OBJECT_REFERENCE,
"PDFObjectType::Reference value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::Unknown) == FPDF_TEXTRENDERMODE_UNKNOWN,
+ "PDFTextRenderMode::Unknown value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::Fill) == FPDF_TEXTRENDERMODE_FILL,
+ "PDFTextRenderMode::Fill value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::Stroke) == FPDF_TEXTRENDERMODE_STROKE,
+ "PDFTextRenderMode::Stroke value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::FillStroke)
+ == FPDF_TEXTRENDERMODE_FILL_STROKE,
+ "PDFTextRenderMode::FillStroke value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::Invisible)
+ == FPDF_TEXTRENDERMODE_INVISIBLE,
+ "PDFTextRenderMode::Invisible value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::FillClip)
+ == FPDF_TEXTRENDERMODE_FILL_CLIP,
+ "PDFTextRenderMode::FillClip value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::StrokeClip)
+ == FPDF_TEXTRENDERMODE_STROKE_CLIP,
+ "PDFTextRenderMode::StrokeClip value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::FillStrokeClip)
+ == FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP,
+ "PDFTextRenderMode::FillStrokeClip value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::Clip) == FPDF_TEXTRENDERMODE_CLIP,
+ "PDFTextRenderMode::Clip value mismatch");
+
namespace
{
/// Callback class to be used with FPDF_SaveWithVersion().
@@ -615,7 +639,10 @@ OUString PDFiumPageObject::getFontName()
return sFontName;
}
-int PDFiumPageObject::getTextRenderMode() { return FPDFTextObj_GetTextRenderMode(mpPageObject); }
+PDFTextRenderMode PDFiumPageObject::getTextRenderMode()
+{
+ return static_cast<PDFTextRenderMode>(FPDFTextObj_GetTextRenderMode(mpPageObject));
+}
Color PDFiumPageObject::getFillColor()
{