[Libreoffice-commits] core.git: include/vcl vcl/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Dec 9 08:24:37 UTC 2020
include/vcl/filter/PDFiumLibrary.hxx | 28 +++++++-----------
vcl/source/pdf/PDFiumLibrary.cxx | 54 +++++++++++++++++++++++++----------
2 files changed, 51 insertions(+), 31 deletions(-)
New commits:
commit ff2a8e6c28650cdd361fa99e6e5d4782ad56c330
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Dec 8 21:07:35 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Dec 9 09:24:03 2020 +0100
pdfium: rework to eliminate FPDF_BITMAP from the public interface
Change-Id: I8be708d801ebaebc7d1b42bbaa6afa29901b4f5b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107438
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 6e952d4fc17b..1c0ccf581343 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -70,25 +70,19 @@ public:
class PDFiumPage;
-class VCL_DLLPUBLIC PDFiumBitmap final
+class VCL_DLLPUBLIC PDFiumBitmap
{
-private:
- FPDF_BITMAP mpBitmap;
-
- PDFiumBitmap(const PDFiumBitmap&) = delete;
- PDFiumBitmap& operator=(const PDFiumBitmap&) = delete;
-
public:
- PDFiumBitmap(FPDF_BITMAP pBitmap);
- ~PDFiumBitmap();
- FPDF_BITMAP getPointer() { return mpBitmap; }
- void fillRect(int left, int top, int width, int height, sal_uInt32 nColor);
- void renderPageBitmap(PDFiumPage* pPage, int nStartX, int nStartY, int nSizeX, int nSizeY);
- ConstScanline getBuffer();
- int getStride();
- int getWidth();
- int getHeight();
- PDFBitmapType getFormat();
+ virtual ~PDFiumBitmap() = default;
+ virtual void fillRect(int left, int top, int width, int height, sal_uInt32 nColor) = 0;
+ virtual void renderPageBitmap(PDFiumPage* pPage, int nStartX, int nStartY, int nSizeX,
+ int nSizeY)
+ = 0;
+ virtual ConstScanline getBuffer() = 0;
+ virtual int getStride() = 0;
+ virtual int getWidth() = 0;
+ virtual int getHeight() = 0;
+ virtual PDFBitmapType getFormat() = 0;
};
class VCL_DLLPUBLIC PDFiumAnnotation final
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 00a3167bfa36..cf435ac419c8 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -85,6 +85,32 @@ int CompatibleWriterCallback(FPDF_FILEWRITE* pFileWrite, const void* pData, unsi
namespace vcl::pdf
{
+namespace
+{
+class PDFiumBitmapImpl final : public PDFiumBitmap
+{
+private:
+ FPDF_BITMAP mpBitmap;
+
+ PDFiumBitmapImpl(const PDFiumBitmapImpl&) = delete;
+ PDFiumBitmapImpl& operator=(const PDFiumBitmapImpl&) = delete;
+
+public:
+ PDFiumBitmapImpl(FPDF_BITMAP pBitmap);
+ ~PDFiumBitmapImpl() override;
+ FPDF_BITMAP getPointer() { return mpBitmap; }
+
+ void fillRect(int left, int top, int width, int height, sal_uInt32 nColor) override;
+ void renderPageBitmap(PDFiumPage* pPage, int nStartX, int nStartY, int nSizeX,
+ int nSizeY) override;
+ ConstScanline getBuffer() override;
+ int getStride() override;
+ int getWidth() override;
+ int getHeight() override;
+ PDFBitmapType getFormat() override;
+};
+}
+
OUString convertPdfDateToISO8601(OUString const& rInput)
{
if (rInput.getLength() < 6)
@@ -208,7 +234,7 @@ std::unique_ptr<PDFiumBitmap> PDFium::createBitmap(int nWidth, int nHeight, int
}
else
{
- pPDFiumBitmap = std::make_unique<PDFiumBitmap>(pPdfBitmap);
+ pPDFiumBitmap = std::make_unique<PDFiumBitmapImpl>(pPdfBitmap);
}
return pPDFiumBitmap;
}
@@ -560,7 +586,7 @@ std::unique_ptr<PDFiumBitmap> PDFiumPageObject::getImageBitmap()
FPDF_BITMAP pBitmap = FPDFImageObj_GetBitmap(mpPageObject);
if (pBitmap)
{
- pPDFiumBitmap = std::make_unique<PDFiumBitmap>(pBitmap);
+ pPDFiumBitmap = std::make_unique<PDFiumBitmapImpl>(pBitmap);
}
return pPDFiumBitmap;
}
@@ -569,8 +595,8 @@ BitmapChecksum PDFiumPage::getChecksum(int nMDPPerm)
{
size_t nPageWidth = getWidth();
size_t nPageHeight = getHeight();
- auto pPdfBitmap
- = std::make_unique<PDFiumBitmap>(FPDFBitmap_Create(nPageWidth, nPageHeight, /*alpha=*/1));
+ auto pPdfBitmap = std::make_unique<PDFiumBitmapImpl>(
+ FPDFBitmap_Create(nPageWidth, nPageHeight, /*alpha=*/1));
if (!pPdfBitmap)
{
return 0;
@@ -629,12 +655,12 @@ PDFSegmentType PDFiumPathSegment::getType() const
return static_cast<PDFSegmentType>(FPDFPathSegment_GetType(mpPathSegment));
}
-PDFiumBitmap::PDFiumBitmap(FPDF_BITMAP pBitmap)
+PDFiumBitmapImpl::PDFiumBitmapImpl(FPDF_BITMAP pBitmap)
: mpBitmap(pBitmap)
{
}
-PDFiumBitmap::~PDFiumBitmap()
+PDFiumBitmapImpl::~PDFiumBitmapImpl()
{
if (mpBitmap)
{
@@ -642,30 +668,30 @@ PDFiumBitmap::~PDFiumBitmap()
}
}
-void PDFiumBitmap::fillRect(int left, int top, int width, int height, sal_uInt32 nColor)
+void PDFiumBitmapImpl::fillRect(int left, int top, int width, int height, sal_uInt32 nColor)
{
FPDFBitmap_FillRect(mpBitmap, left, top, width, height, nColor);
}
-void PDFiumBitmap::renderPageBitmap(PDFiumPage* pPage, int nStartX, int nStartY, int nSizeX,
- int nSizeY)
+void PDFiumBitmapImpl::renderPageBitmap(PDFiumPage* pPage, int nStartX, int nStartY, int nSizeX,
+ int nSizeY)
{
FPDF_RenderPageBitmap(mpBitmap, pPage->getPointer(), nStartX, nStartY, nSizeX, nSizeY,
/*rotate=*/0, /*flags=*/0);
}
-ConstScanline PDFiumBitmap::getBuffer()
+ConstScanline PDFiumBitmapImpl::getBuffer()
{
return static_cast<ConstScanline>(FPDFBitmap_GetBuffer(mpBitmap));
}
-int PDFiumBitmap::getStride() { return FPDFBitmap_GetStride(mpBitmap); }
+int PDFiumBitmapImpl::getStride() { return FPDFBitmap_GetStride(mpBitmap); }
-int PDFiumBitmap::getWidth() { return FPDFBitmap_GetWidth(mpBitmap); }
+int PDFiumBitmapImpl::getWidth() { return FPDFBitmap_GetWidth(mpBitmap); }
-int PDFiumBitmap::getHeight() { return FPDFBitmap_GetHeight(mpBitmap); }
+int PDFiumBitmapImpl::getHeight() { return FPDFBitmap_GetHeight(mpBitmap); }
-PDFBitmapType PDFiumBitmap::getFormat()
+PDFBitmapType PDFiumBitmapImpl::getFormat()
{
return static_cast<PDFBitmapType>(FPDFBitmap_GetFormat(mpBitmap));
}
More information about the Libreoffice-commits
mailing list