From dfee8ca7095a293fc58877aa299aaaa4a789392c Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Wed, 6 Jun 2018 00:51:10 -0400 Subject: vcl: svx: misc improvements to pdfium importing Change-Id: I58f2fd973a731b148f40b37139cd74bac097a7d2 --- include/svx/xmlgrhlp.hxx | 1 + include/vcl/graph.hxx | 2 +- include/vcl/pdfread.hxx | 2 +- sd/source/filter/pdf/sdpdffilter.cxx | 2 +- sdext/source/pdfimport/wrapper/wrapper.cxx | 2 +- svx/source/svdraw/svdpdf.cxx | 2 +- svx/source/xml/xmlgrhlp.cxx | 8 ++++---- svx/source/xoutdev/_xoutbmp.cxx | 4 ++-- vcl/source/filter/ipdf/pdfread.cxx | 6 +++--- vcl/source/gdi/graph.cxx | 2 +- vcl/source/gdi/impgraph.cxx | 3 ++- 11 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/svx/xmlgrhlp.hxx b/include/svx/xmlgrhlp.hxx index d6973104f72e..4d9fa58a1b49 100644 --- a/include/svx/xmlgrhlp.hxx +++ b/include/svx/xmlgrhlp.hxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index cd2e48c273f7..24c3f4e796a2 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -231,7 +231,7 @@ public: const VectorGraphicDataPtr& getVectorGraphicData() const; void setPdfData(const std::shared_ptr>& rPdfData); - std::shared_ptr> getPdfData() const; + const std::shared_ptr>& getPdfData() const; bool hasPdfData() const; /// Set the page number of the multi-page source this Graphic is rendered from. diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx index 2e3f2fa36994..0fc3249cd6a3 100644 --- a/include/vcl/pdfread.hxx +++ b/include/vcl/pdfread.hxx @@ -10,8 +10,8 @@ #ifndef INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX #define INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX -#include #include +#include namespace com { diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index ad00ae0ba0ba..7f58ba6c8d1f 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -144,7 +144,7 @@ bool SdPdfFilter::Import() Point aPos(0, 0); pPage->InsertObject(new SdrGrafObj(pPage->getSdrModelFromSdrPage(), aGraphic, - ::tools::Rectangle(aPos, aGrfSize))); + tools::Rectangle(aPos, aGrfSize))); } return true; diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index affd350a6a8c..d34573d65ee6 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -1009,7 +1009,7 @@ public: }; bool xpdf_ImportFromFile(const OUString& rURL, - const ContentSinkSharedPtr& rSink, + const ContentSinkSharedPtr& rSink, const uno::Reference& xIHdl, const OUString& rPwd, const uno::Reference& xContext, diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index b47a6aadc16c..020141784d13 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -971,7 +971,7 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const Size& rSize, const OUS Size aSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * mfScaleY)); if (eAlg == ALIGN_BASELINE) - aPos.AdjustY(-(FRound(aFontMetric.GetAscent() * mfScaleY))); + aPos.AdjustY(-FRound(aFontMetric.GetAscent() * mfScaleY)); else if (eAlg == ALIGN_BOTTOM) aPos.AdjustY(-nTextHeight); diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 238b8dda3c91..988341d528e1 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -764,10 +764,11 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference pStream(utl::UcbStreamHelper::CreateStream(aStream.xStream)); if (bUseGfxLink && aGfxLink.GetDataSize() && aGfxLink.GetData()) { - if (aGraphic.hasPdfData()) + const std::shared_ptr>& rPdfData = aGraphic.getPdfData(); + if (rPdfData && rPdfData->hasElements()) { // See if we have this PDF already, and avoid duplicate storage. - auto aIt = maExportPdf.find(aGraphic.getPdfData().get()); + auto aIt = maExportPdf.find(rPdfData.get()); if (aIt != maExportPdf.end()) { auto const& aURLAndMimePair = aIt->second; @@ -779,8 +780,7 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference> pPdfData = aGraphic.getPdfData(); - pStream->WriteBytes(pPdfData->getConstArray(), pPdfData->getLength()); + pStream->WriteBytes(rPdfData->getConstArray(), rPdfData->getLength()); } else { diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index a37508c2fcd1..05998009e14a 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -182,8 +182,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()) { - std::shared_ptr> pPdfData = rGraphic.getPdfData(); - pOutStream->WriteBytes(pPdfData->getConstArray(), pPdfData->getLength()); + const std::shared_ptr>& rPdfData = rGraphic.getPdfData(); + pOutStream->WriteBytes(rPdfData->getConstArray(), rPdfData->getLength()); aMedium.Commit(); if (!aMedium.GetError()) nErr = ERRCODE_NONE; diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index 4ac2503ec665..d98c856c6704 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -60,7 +60,7 @@ inline double pointToPixel(const double fPoint, const double fResolutionDPI) /// Does PDF to bitmap conversion using pdfium. size_t generatePreview(SvStream& rStream, std::vector& rBitmaps, sal_uInt64 nPos, - sal_uInt64 nSize, const size_t nFirstPage = 0, int nPages = 1, + sal_uInt64 nSize, const size_t nFirstPage, int nPages, const double fResolutionDPI = 96.) { FPDF_LIBRARY_CONFIG aConfig; @@ -197,7 +197,7 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream, sal_uInt64 n } #else size_t generatePreview(SvStream&, std::vector&, sal_uInt64 nPos, sal_uInt64 nSize, - size_t nFirstPage = 0, int nLastPage = 0, const double fResolutionDPI = 96.) + size_t nFirstPage, int nLastPage, const double fResolutionDPI = 96.) { (void)rStream; (void)rBitmap; @@ -207,7 +207,7 @@ size_t generatePreview(SvStream&, std::vector&, sal_uInt64 nPos, sal_uIn (void)nLastPage; (void)fResolutionDPI; - return false; + return 0; } bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream, sal_uInt64 nPos, diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index adc7d771c94d..52e4e9e74ae8 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -563,7 +563,7 @@ void Graphic::setPdfData(const std::shared_ptr>& rPdfDat mxImpGraphic->setPdfData(rPdfData); } -std::shared_ptr> Graphic::getPdfData() const +const std::shared_ptr>& Graphic::getPdfData() const { return mxImpGraphic->getPdfData(); } diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 32c8dfee44a8..87a7bd64a398 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -242,7 +242,8 @@ ImpGraphic::ImpGraphic(GraphicExternalLink const & rGraphicExternalLink) : mbDummyContext ( false ), maGraphicExternalLink(rGraphicExternalLink), maLastUsed (std::chrono::high_resolution_clock::now()), - mbPrepared (false) + mbPrepared (false), + mnPageNumber(-1) { } -- cgit