[Libreoffice-commits] core.git: include/vcl vcl/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Fri Feb 19 07:34:02 UTC 2021
include/vcl/filter/PDFiumLibrary.hxx | 41 ++++++++--------------------
vcl/source/pdf/PDFiumLibrary.cxx | 51 ++++++++++++++++++++++++++---------
2 files changed, 51 insertions(+), 41 deletions(-)
New commits:
commit efb093893ffe9aa6340bde72e12d0512200d2100
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Feb 18 20:49:54 2021 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Feb 19 08:33:22 2021 +0100
pdfium: eliminate FPDF_DOCUMENT from public header
Which means the last pdfium include can go from PDFiumLibrary.hxx.
Change-Id: I73e40767f594c9a6ce75582621af975419ccf996
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111163
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 7bf14eb910dc..d65658769e84 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -10,15 +10,11 @@
#pragma once
-#include <config_features.h>
+#include <memory>
#include <com/sun/star/util/DateTime.hpp>
-#if HAVE_FEATURE_PDFIUM
-
#include <vcl/dllapi.h>
-
-#include <memory>
#include <rtl/instance.hxx>
#include <basegfx/vector/b2dsize.hxx>
#include <basegfx/range/b2drectangle.hxx>
@@ -39,8 +35,6 @@
#include <vcl/pdf/PDFFindFlags.hxx>
#include <vcl/pdf/PDFErrorType.hxx>
-#include <fpdf_doc.h>
-
class SvMemoryStream;
namespace vcl::pdf
@@ -217,30 +211,21 @@ public:
virtual css::util::DateTime getTime() = 0;
};
-class VCL_DLLPUBLIC PDFiumDocument final
+class VCL_DLLPUBLIC PDFiumDocument
{
-private:
- FPDF_DOCUMENT mpPdfDocument;
-
-private:
- PDFiumDocument(const PDFiumDocument&) = delete;
- PDFiumDocument& operator=(const PDFiumDocument&) = delete;
-
public:
- PDFiumDocument(FPDF_DOCUMENT pPdfDocument);
- ~PDFiumDocument();
- FPDF_DOCUMENT getPointer() { return mpPdfDocument; }
+ virtual ~PDFiumDocument() = default;
// Page size in points
- basegfx::B2DSize getPageSize(int nIndex);
- int getPageCount();
- int getSignatureCount();
- int getFileVersion();
- bool saveWithVersion(SvMemoryStream& rStream, int nFileVersion);
-
- std::unique_ptr<PDFiumPage> openPage(int nIndex);
- std::unique_ptr<PDFiumSignature> getSignature(int nIndex);
- std::vector<unsigned int> getTrailerEnds();
+ virtual basegfx::B2DSize getPageSize(int nIndex) = 0;
+ virtual int getPageCount() = 0;
+ virtual int getSignatureCount() = 0;
+ virtual int getFileVersion() = 0;
+ virtual bool saveWithVersion(SvMemoryStream& rStream, int nFileVersion) = 0;
+
+ virtual std::unique_ptr<PDFiumPage> openPage(int nIndex) = 0;
+ virtual std::unique_ptr<PDFiumSignature> getSignature(int nIndex) = 0;
+ virtual std::vector<unsigned int> getTrailerEnds() = 0;
};
struct PDFiumLibrary final : public rtl::StaticWithInit<std::shared_ptr<PDFium>, PDFiumLibrary>
@@ -254,6 +239,4 @@ VCL_DLLPUBLIC OUString convertPdfDateToISO8601(OUString const& rInput);
} // namespace vcl::pdf
-#endif // HAVE_FEATURE_PDFIUM
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index fda247861913..232ed10cb9b6 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -12,9 +12,11 @@
#if HAVE_FEATURE_PDFIUM
+#include <vcl/filter/PDFiumLibrary.hxx>
+
#include <cassert>
-#include <vcl/filter/PDFiumLibrary.hxx>
+#include <fpdf_doc.h>
#include <fpdf_annot.h>
#include <fpdf_edit.h>
#include <fpdf_text.h>
@@ -367,6 +369,31 @@ public:
bool hasLinks() override;
};
+
+class PDFiumDocumentImpl : public PDFiumDocument
+{
+private:
+ FPDF_DOCUMENT mpPdfDocument;
+
+private:
+ PDFiumDocumentImpl(const PDFiumDocumentImpl&) = delete;
+ PDFiumDocumentImpl& operator=(const PDFiumDocumentImpl&) = delete;
+
+public:
+ PDFiumDocumentImpl(FPDF_DOCUMENT pPdfDocument);
+ ~PDFiumDocumentImpl() override;
+
+ // Page size in points
+ basegfx::B2DSize getPageSize(int nIndex) override;
+ int getPageCount() override;
+ int getSignatureCount() override;
+ int getFileVersion() override;
+ bool saveWithVersion(SvMemoryStream& rStream, int nFileVersion) override;
+
+ std::unique_ptr<PDFiumPage> openPage(int nIndex) override;
+ std::unique_ptr<PDFiumSignature> getSignature(int nIndex) override;
+ std::vector<unsigned int> getTrailerEnds() override;
+};
}
OUString convertPdfDateToISO8601(OUString const& rInput)
@@ -476,7 +503,7 @@ std::unique_ptr<PDFiumDocument> PDFium::openDocument(const void* pData, int nSiz
}
else
{
- pPDFiumDocument = std::make_unique<PDFiumDocument>(pDocument);
+ pPDFiumDocument = std::make_unique<PDFiumDocumentImpl>(pDocument);
}
return pPDFiumDocument;
@@ -584,18 +611,18 @@ util::DateTime PDFiumSignatureImpl::getTime()
return aRet;
}
-PDFiumDocument::PDFiumDocument(FPDF_DOCUMENT pPdfDocument)
+PDFiumDocumentImpl::PDFiumDocumentImpl(FPDF_DOCUMENT pPdfDocument)
: mpPdfDocument(pPdfDocument)
{
}
-PDFiumDocument::~PDFiumDocument()
+PDFiumDocumentImpl::~PDFiumDocumentImpl()
{
if (mpPdfDocument)
FPDF_CloseDocument(mpPdfDocument);
}
-std::unique_ptr<PDFiumPage> PDFiumDocument::openPage(int nIndex)
+std::unique_ptr<PDFiumPage> PDFiumDocumentImpl::openPage(int nIndex)
{
std::unique_ptr<PDFiumPage> pPDFiumPage;
FPDF_PAGE pPage = FPDF_LoadPage(mpPdfDocument, nIndex);
@@ -606,7 +633,7 @@ std::unique_ptr<PDFiumPage> PDFiumDocument::openPage(int nIndex)
return pPDFiumPage;
}
-std::unique_ptr<PDFiumSignature> PDFiumDocument::getSignature(int nIndex)
+std::unique_ptr<PDFiumSignature> PDFiumDocumentImpl::getSignature(int nIndex)
{
std::unique_ptr<PDFiumSignature> pPDFiumSignature;
FPDF_SIGNATURE pSignature = FPDF_GetSignatureObject(mpPdfDocument, nIndex);
@@ -617,7 +644,7 @@ std::unique_ptr<PDFiumSignature> PDFiumDocument::getSignature(int nIndex)
return pPDFiumSignature;
}
-std::vector<unsigned int> PDFiumDocument::getTrailerEnds()
+std::vector<unsigned int> PDFiumDocumentImpl::getTrailerEnds()
{
int nNumTrailers = FPDF_GetTrailerEnds(mpPdfDocument, nullptr, 0);
std::vector<unsigned int> aTrailerEnds(nNumTrailers);
@@ -625,7 +652,7 @@ std::vector<unsigned int> PDFiumDocument::getTrailerEnds()
return aTrailerEnds;
}
-basegfx::B2DSize PDFiumDocument::getPageSize(int nIndex)
+basegfx::B2DSize PDFiumDocumentImpl::getPageSize(int nIndex)
{
basegfx::B2DSize aSize;
FS_SIZEF aPDFSize;
@@ -636,18 +663,18 @@ basegfx::B2DSize PDFiumDocument::getPageSize(int nIndex)
return aSize;
}
-int PDFiumDocument::getPageCount() { return FPDF_GetPageCount(mpPdfDocument); }
+int PDFiumDocumentImpl::getPageCount() { return FPDF_GetPageCount(mpPdfDocument); }
-int PDFiumDocument::getSignatureCount() { return FPDF_GetSignatureCount(mpPdfDocument); }
+int PDFiumDocumentImpl::getSignatureCount() { return FPDF_GetSignatureCount(mpPdfDocument); }
-int PDFiumDocument::getFileVersion()
+int PDFiumDocumentImpl::getFileVersion()
{
int nFileVersion = 0;
FPDF_GetFileVersion(mpPdfDocument, &nFileVersion);
return nFileVersion;
}
-bool PDFiumDocument::saveWithVersion(SvMemoryStream& rStream, int nFileVersion)
+bool PDFiumDocumentImpl::saveWithVersion(SvMemoryStream& rStream, int nFileVersion)
{
CompatibleWriter aWriter(rStream);
aWriter.version = 1;
More information about the Libreoffice-commits
mailing list