summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-01-14 21:20:31 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-01-15 08:35:11 +0100
commit97601533cbef67bfdb5f25dc00d0dda743e8349e (patch)
tree6eae76971eeff1980c6f82289055b708e6f20621
parent61a3aaae61dfb6d9538eeeed4721d44293d737f4 (diff)
pdfium: add wrapper for FPDF_FILLMODE_* defines
Which is, I think, the last direct pdfium usage outside vcl. Change-Id: I2e435e5a3669c6163bf2c20bc6d1d8bd4c88cecd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109314 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--include/vcl/filter/PDFiumLibrary.hxx2
-rw-r--r--include/vcl/pdf/PDFFillMode.hxx24
-rw-r--r--svx/source/svdraw/svdpdf.cxx10
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx17
4 files changed, 48 insertions, 5 deletions
diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx
index eee97e39bf9a..79f91c6f5264 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -35,6 +35,7 @@
#include <vcl/pdf/PDFBitmapType.hxx>
#include <vcl/pdf/PDFObjectType.hxx>
#include <vcl/pdf/PDFTextRenderMode.hxx>
+#include <vcl/pdf/PDFFillMode.hxx>
#include <fpdf_doc.h>
@@ -154,6 +155,7 @@ public:
std::unique_ptr<PDFiumPathSegment> getPathSegment(int index);
Size getImageSize(PDFiumPage& rPage);
std::unique_ptr<PDFiumBitmap> getImageBitmap();
+ bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke);
};
class VCL_DLLPUBLIC PDFiumTextPage final
diff --git a/include/vcl/pdf/PDFFillMode.hxx b/include/vcl/pdf/PDFFillMode.hxx
new file mode 100644
index 000000000000..e5bc71f0d16a
--- /dev/null
+++ b/include/vcl/pdf/PDFFillMode.hxx
@@ -0,0 +1,24 @@
+/* -*- 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 PDFFillMode
+{
+ None = 0,
+ Alternate = 1,
+ Winding = 2,
+};
+
+} // 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 e266609bd295..75f079540935 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1011,13 +1011,13 @@ void ImpSdrPdfImport::ImportPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> con
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->getPointer(), &nFillMode, &bStroke))
+ vcl::pdf::PDFFillMode nFillMode = vcl::pdf::PDFFillMode::Alternate;
+ bool bStroke = true; // Assume we have to draw, unless told otherwise.
+ if (pPageObject->getDrawMode(nFillMode, bStroke))
{
- if (nFillMode == FPDF_FILLMODE_ALTERNATE)
+ if (nFillMode == vcl::pdf::PDFFillMode::Alternate)
mpVD->SetDrawMode(DrawModeFlags::Default);
- else if (nFillMode == FPDF_FILLMODE_WINDING)
+ else if (nFillMode == vcl::pdf::PDFFillMode::Winding)
mpVD->SetDrawMode(DrawModeFlags::Default);
else
mpVD->SetDrawMode(DrawModeFlags::NoFill);
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 755c19684183..bdd3fed7b4d4 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -107,6 +107,13 @@ static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::FillStrokeClip)
static_assert(static_cast<int>(vcl::pdf::PDFTextRenderMode::Clip) == FPDF_TEXTRENDERMODE_CLIP,
"PDFTextRenderMode::Clip value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFFillMode::None) == FPDF_FILLMODE_NONE,
+ "PDFFillMode::None value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFFillMode::Alternate) == FPDF_FILLMODE_ALTERNATE,
+ "PDFFillMode::Alternate value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFFillMode::Winding) == FPDF_FILLMODE_WINDING,
+ "PDFFillMode::Winding value mismatch");
+
namespace
{
/// Callback class to be used with FPDF_SaveWithVersion().
@@ -704,6 +711,16 @@ std::unique_ptr<PDFiumBitmap> PDFiumPageObject::getImageBitmap()
return pPDFiumBitmap;
}
+bool PDFiumPageObject::getDrawMode(PDFFillMode& rFillMode, bool& rStroke)
+{
+ auto nFillMode = static_cast<int>(rFillMode);
+ auto bStroke = static_cast<FPDF_BOOL>(rStroke);
+ bool bRet = FPDFPath_GetDrawMode(mpPageObject, &nFillMode, &bStroke);
+ rFillMode = static_cast<PDFFillMode>(nFillMode);
+ rStroke = static_cast<bool>(bStroke);
+ return bRet;
+}
+
BitmapChecksum PDFiumPage::getChecksum(int nMDPPerm)
{
size_t nPageWidth = getWidth();