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

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Sun Aug 25 11:34:06 UTC 2019


 sd/source/filter/pdf/sdpdffilter.cxx |    3 +--
 vcl/source/filter/ipdf/pdfread.cxx   |   12 +++++-------
 2 files changed, 6 insertions(+), 9 deletions(-)

New commits:
commit 7fc0ddd9b725e3ea955bb06ef82f6a99de706210
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Jun 22 10:28:42 2018 +0200
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Sun Aug 25 13:32:55 2019 +0200

    pdfium: Avoid unnecessary copying + some warning fixes.
    
    Reviewed-on: https://gerrit.libreoffice.org/56285
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 4ab8dde71c8580bcf2b222ae2d1f68bbe339c754)
    
    Change-Id: I114fa6b2d3dda86c55eb245d31ca3a1019197ae9
    Reviewed-on: https://gerrit.libreoffice.org/77689
    Tested-by: Jenkins
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 0cf7baa9dd6c..cbd83075338d 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -71,8 +71,7 @@ bool SdPdfFilter::Import()
         const Size& aSize = aPair.second;
 
         const sal_Int32 nPageNumber = rGraphic.getPageNumber();
-        if (nPageNumber < 0 || static_cast<size_t>(nPageNumber) >= aGraphics.size())
-            continue; // Page is out of range
+        assert(nPageNumber >= 0 && static_cast<size_t>(nPageNumber) < aGraphics.size());
 
         // Create the page and insert the Graphic.
         SdPage* pPage = mrDocument.GetSdPage(nPageNumber, PageKind::Standard);
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index d9c197bffd77..3687f301b2e9 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -283,19 +283,17 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si
         return 0;
 
     // Copy into PdfData
-    uno::Sequence<sal_Int8> aPdfData;
     aMemoryStream.Seek(STREAM_SEEK_TO_END);
-    aPdfData = css::uno::Sequence<sal_Int8>(aMemoryStream.Tell());
+    auto pPdfData = std::make_shared<css::uno::Sequence<sal_Int8>>(aMemoryStream.Tell());
     aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
-    aMemoryStream.ReadBytes(aPdfData.getArray(), aPdfData.getLength());
+    aMemoryStream.ReadBytes(pPdfData->getArray(), pPdfData->getLength());
 
     // Prepare the link with the PDF stream.
-    const size_t nGraphicContentSize = aPdfData.getLength();
+    const size_t nGraphicContentSize = pPdfData->getLength();
     std::unique_ptr<sal_uInt8[]> pGraphicContent(new sal_uInt8[nGraphicContentSize]);
-    memcpy(pGraphicContent.get(), aPdfData.get(), nGraphicContentSize);
+    memcpy(pGraphicContent.get(), pPdfData->get(), nGraphicContentSize);
     std::shared_ptr<GfxLink> pGfxLink(std::make_shared<GfxLink>(
         std::move(pGraphicContent), nGraphicContentSize, GfxLinkType::NativePdf));
-    auto pPdfData = std::make_shared<uno::Sequence<sal_Int8>>(aPdfData);
 
     FPDF_LIBRARY_CONFIG aConfig;
     aConfig.version = 2;
@@ -306,7 +304,7 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si
 
     // Load the buffer using pdfium.
     FPDF_DOCUMENT pPdfDocument
-        = FPDF_LoadMemDocument(aPdfData.getArray(), aPdfData.getLength(), /*password=*/nullptr);
+        = FPDF_LoadMemDocument(pPdfData->getArray(), pPdfData->getLength(), /*password=*/nullptr);
     if (!pPdfDocument)
         return 0;
 


More information about the Libreoffice-commits mailing list