From eb581eff6ac41b938299b4c154ded6891bdd0c11 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Tue, 2 Apr 2019 22:12:28 +0200 Subject: pdfium: Use std::vector to hold the PdfData. This fixes the destruction of the static cache of the PDF data; without this, there were already missing uno runtime info. (cherry picked from commit 20055ebe1b27f716a2acf1f0f4dda2864ae811bf) Change-Id: I877c9ccf96c4b7eabf3d643e17f324d86d987f94 Reviewed-on: https://gerrit.libreoffice.org/77691 Tested-by: Jenkins Reviewed-by: Ashod Nakashian --- svx/source/svdraw/svdograf.cxx | 6 +++--- svx/source/svdraw/svdpdf.cxx | 4 ++-- svx/source/svdraw/svdpdf.hxx | 4 ++-- svx/source/xml/xmlgrhlp.cxx | 8 ++++---- svx/source/xoutdev/_xoutbmp.cxx | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'svx/source') diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index c74de64e69a4..8ac19ae1525a 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -145,6 +145,7 @@ std::unique_ptr SdrGrafObj::CreateObjectSpecificViewC return std::make_unique(*this); } + // check if SVG and if try to get ObjectInfoPrimitive2D and extract info void SdrGrafObj::onGraphicChanged() @@ -342,7 +343,6 @@ void SdrGrafObj::SetGraphic( const Graphic& rGraphic ) const Graphic& SdrGrafObj::GetGraphic() const { - ForceSwapIn(); return mpGraphicObject->GetGraphic(); } @@ -463,6 +463,7 @@ Size SdrGrafObj::getOriginalSize() const return aSize; } +// TODO Remove void SdrGrafObj::ForceSwapIn() const { if (pGraphicLink && (mpGraphicObject->GetType() == GraphicType::NONE || @@ -711,7 +712,6 @@ SdrObject* SdrGrafObj::getFullDragClone() const // temporary interaction object and load graphic if(pRetval && IsLinkedGraphic()) { - pRetval->ForceSwapIn(); pRetval->ReleaseGraphicLink(); } @@ -907,7 +907,7 @@ bool SdrGrafObj::isEmbeddedPdfData() const return mpGraphicObject->GetGraphic().hasPdfData(); } -std::shared_ptr> const & SdrGrafObj::getEmbeddedPdfData() const +std::shared_ptr> const & SdrGrafObj::getEmbeddedPdfData() const { return mpGraphicObject->GetGraphic().getPdfData(); } diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 7bcb2cae241d..6ac08e5e7f9d 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -118,7 +118,7 @@ struct FPDFBitmapDeleter using namespace com::sun::star; ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect, - const std::shared_ptr>& pPdfData) + const std::shared_ptr>& pPdfData) : maTmpList() , mpVD(VclPtr::Create()) , maScaleRect(rRect) @@ -166,7 +166,7 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools: FPDF_InitLibraryWithConfig(&aConfig); // Load the buffer using pdfium. - mpPdfDocument = FPDF_LoadMemDocument(mpPdfData->getConstArray(), mpPdfData->getLength(), + mpPdfDocument = FPDF_LoadMemDocument(mpPdfData->data(), mpPdfData->size(), /*password=*/nullptr); if (!mpPdfDocument) { diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx index bc3ba11946f6..70b5a44e4ddf 100644 --- a/svx/source/svdraw/svdpdf.hxx +++ b/svx/source/svdraw/svdpdf.hxx @@ -161,7 +161,7 @@ class ImpSdrPdfImport final ::std::vector maTmpList; ScopedVclPtr mpVD; tools::Rectangle const maScaleRect; - const std::shared_ptr> mpPdfData; + const std::shared_ptr> mpPdfData; size_t mnMapScalingOfs; // from here on, not edited with MapScaling std::unique_ptr mpLineAttr; std::unique_ptr mpFillAttr; @@ -233,7 +233,7 @@ class ImpSdrPdfImport final public: ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect, - const std::shared_ptr>& pPdfData); + const std::shared_ptr>& pPdfData); ~ImpSdrPdfImport(); int GetPageCount() const { return mnPageCount; } diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 1b2536a6a509..1c64d13566d6 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -296,7 +296,7 @@ Graphic SvXMLGraphicOutputStream::GetGraphic() mpOStm->Seek( 0 ); sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW; sal_uInt16 nDeterminedFormat = GRFILTER_FORMAT_DONTKNOW; - GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, "", *mpOStm ,nFormat, &nDeterminedFormat ); + GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, "", *mpOStm ,nFormat,&nDeterminedFormat); if (nDeterminedFormat == GRFILTER_FORMAT_DONTKNOW) { @@ -760,8 +760,8 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference pStream(utl::UcbStreamHelper::CreateStream(aStream.xStream)); if (bUseGfxLink && aGfxLink.GetDataSize() && aGfxLink.GetData()) { - const std::shared_ptr>& rPdfData = aGraphic.getPdfData(); - if (rPdfData && rPdfData->hasElements()) + const std::shared_ptr>& rPdfData = aGraphic.getPdfData(); + if (rPdfData && !rPdfData->empty()) { // See if we have this PDF already, and avoid duplicate storage. auto aIt = maExportPdf.find(rPdfData.get()); @@ -776,7 +776,7 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::ReferenceWriteBytes(rPdfData->getConstArray(), rPdfData->getLength()); + pStream->WriteBytes(rPdfData->data(), rPdfData->size()); } else { diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index 4d33fda7534d..6aeca72a6eb1 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -185,8 +185,8 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, SfxMedium aMedium(aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE|StreamMode::SHARE_DENYNONE|StreamMode::TRUNC); if (SvStream* pOutStream = aMedium.GetOutStream()) { - const std::shared_ptr>& rPdfData = rGraphic.getPdfData(); - pOutStream->WriteBytes(rPdfData->getConstArray(), rPdfData->getLength()); + const std::shared_ptr>& rPdfData = rGraphic.getPdfData(); + pOutStream->WriteBytes(rPdfData->data(), rPdfData->size()); aMedium.Commit(); if (!aMedium.GetError()) nErr = ERRCODE_NONE; -- cgit