summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-06-22 10:28:42 +0200
committerJan Holesovsky <kendy@collabora.com>2019-04-03 17:54:01 +0200
commit335113741b2f4672a7813d8e6410dc5ec1b45527 (patch)
tree73a6ddbcd1a836e551c18464b3471aef5b61daf2 /vcl
parent5a1f367b5573293cf3b2e8dbdffc7de22e99c058 (diff)
pdfium: Avoid unnecessary copying + some warning fixes.
Change-Id: I114fa6b2d3dda86c55eb245d31ca3a1019197ae9 Reviewed-on: https://gerrit.libreoffice.org/56285 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx12
1 files changed, 5 insertions, 7 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 324218ead522..3a058bb36b57 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -301,19 +301,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;
@@ -324,7 +322,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;