[Libreoffice-commits] core.git: include/vcl svx/source vcl/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 15 07:35:51 UTC 2021


 include/vcl/filter/PDFiumLibrary.hxx |    2 ++
 include/vcl/pdf/PDFFillMode.hxx      |   24 ++++++++++++++++++++++++
 svx/source/svdraw/svdpdf.cxx         |   10 +++++-----
 vcl/source/pdf/PDFiumLibrary.cxx     |   17 +++++++++++++++++
 4 files changed, 48 insertions(+), 5 deletions(-)

New commits:
commit 97601533cbef67bfdb5f25dc00d0dda743e8349e
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jan 14 21:20:31 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 15 08:35:11 2021 +0100

    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 at collabora.com>

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();


More information about the Libreoffice-commits mailing list