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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 10 07:04:49 UTC 2019


 vcl/source/filter/ipdf/pdfread.cxx |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

New commits:
commit 3c24774d85a8c0ac03faa4ba2b82c8c9dfe0a2b3
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Apr 9 21:48:03 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Apr 10 09:04:24 2019 +0200

    vcl PDF import: clean up CompatibleWriter
    
    It's cleaner to avoid member functions and constructors when we inherit
    from a C struct and we pass it to pdfium's C API.
    
    Change-Id: Iac9ab99b3d1b66241bb49d3a7707e242078ab5df
    Reviewed-on: https://gerrit.libreoffice.org/70472
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 9815e89a1a2b..edd354f19e5b 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -30,22 +30,10 @@ namespace
 /// Callback class to be used with FPDF_SaveWithVersion().
 struct CompatibleWriter : public FPDF_FILEWRITE
 {
-public:
-    CompatibleWriter();
-    static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* pData,
-                                  unsigned long nSize);
-
     SvMemoryStream m_aStream;
 };
 
-CompatibleWriter::CompatibleWriter()
-{
-    FPDF_FILEWRITE::version = 1;
-    FPDF_FILEWRITE::WriteBlock = CompatibleWriter::WriteBlockCallback;
-}
-
-int CompatibleWriter::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* pData,
-                                         unsigned long nSize)
+int CompatibleWriterCallback(FPDF_FILEWRITE* pFileWrite, const void* pData, unsigned long nSize)
 {
     auto pImpl = static_cast<CompatibleWriter*>(pFileWrite);
     pImpl->m_aStream.WriteBytes(pData, nSize);
@@ -182,6 +170,9 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream, sal_uInt64 n
             return false;
 
         CompatibleWriter aWriter;
+        aWriter.version = 1;
+        aWriter.WriteBlock = &CompatibleWriterCallback;
+
         // 15 means PDF-1.5.
         if (!FPDF_SaveWithVersion(pPdfDocument, &aWriter, 0, 15))
             return false;


More information about the Libreoffice-commits mailing list