sd/source/filter/pdf/sdpdffilter.cxx |    5 ++---
 vcl/source/filter/ipdf/pdfread.cxx   |   12 +++++-------
 2 files changed, 7 insertions(+), 10 deletions(-)

New commits:
commit 3d2b4942214f586f22640e84f6d48fee475521fb
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Fri Jun 22 10:28:42 2018 +0200

    pdfium: Avoid unnecessary copying + some warning fixes.
    
    Change-Id: I114fa6b2d3dda86c55eb245d31ca3a1019197ae9
    Reviewed-on: https://gerrit.libreoffice.org/56285
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/sd/source/filter/pdf/sdpdffilter.cxx 
b/sd/source/filter/pdf/sdpdffilter.cxx
index 62dbc3964f35..e157bef79de8 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -108,7 +108,7 @@ bool SdPdfFilter::Import()
 
     // Add as many pages as we need up-front.
     mrDocument.CreateFirstPages();
-    for (int i = 0; i < aGraphics.size() - 1; ++i)
+    for (size_t i = 0; i < aGraphics.size() - 1; ++i)
     {
         mrDocument.DuplicatePage(0);
     }
@@ -119,8 +119,7 @@ bool SdPdfFilter::Import()
         const Size& aSize = aPair.second;
 
         const sal_Int32 nPageNumber = aGraphic.getPageNumber();
-        if (nPageNumber < 0 || nPageNumber >= aGraphics.size())
-            continue; // Page is out of range
+        assert(nPageNumber >= 0 && nPageNumber < 
static_cast<sal_Int32>(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 e92b0c7b54a3..53008ea5e958 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -317,19 +317,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;
@@ -340,7 +338,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;
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to