diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-06-09 15:31:42 -0400 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-06-17 22:37:58 -0400 |
commit | 13577d3980c0697d157125361bcf4e2dbe4dede9 (patch) | |
tree | 543e243cc0a06d4bb88916f7ff54cc0ada09354e | |
parent | d271bb61e216556887dae60d7b7421c9cf236a1b (diff) |
vcl: maintain shared PdfData across swap-in and -out
private/Ashod/cd-5.3-3.2_import_unloaded_share_GfxLink
Change-Id: I6e434e5b5db0ddcd2fb4d1e522ffdb1c963c1f34
-rw-r--r-- | vcl/source/filter/ipdf/pdfread.cxx | 15 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 6 |
2 files changed, 18 insertions, 3 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index 145653abcfbc..0ce839747c0f 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -268,12 +268,21 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic, if (rGraphic.getPageNumber() < 0) rGraphic.setPageNumber(0); - uno::Sequence<sal_Int8> aPdfData; + if (rGraphic.getPdfData() == nullptr) + rGraphic.setPdfData(std::make_shared<css::uno::Sequence<sal_Int8>>()); + + // Preserve the PdfData, if exists, as it's shared. + std::shared_ptr<css::uno::Sequence<sal_Int8>> pPdfData = rGraphic.getPdfData(); + Bitmap aBitmap; - const bool bRet = ImportPDF(rStream, aBitmap, rGraphic.getPageNumber(), aPdfData, + const bool bRet = ImportPDF(rStream, aBitmap, rGraphic.getPageNumber(), *pPdfData, STREAM_SEEK_TO_BEGIN, STREAM_SEEK_TO_END, fResolutionDPI); + + // Assign the bitmap; will clobber PdfData. rGraphic = aBitmap; - rGraphic.setPdfData(std::make_shared<css::uno::Sequence<sal_Int8>>(aPdfData)); + + // Set PdfData. + rGraphic.setPdfData(pPdfData); return bRet; } diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 2c2ba1bef9ca..bdbf4fa14516 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -387,11 +387,13 @@ bool ImpGraphic::operator==( const ImpGraphic& rImpGraphic ) const void ImpGraphic::setPdfData(const std::shared_ptr<uno::Sequence<sal_Int8>>& rPdfData) { + // No need to swap-in graphic when setting optional PDF data. mpPdfData = rPdfData; } const std::shared_ptr<uno::Sequence<sal_Int8>>& ImpGraphic::getPdfData() const { + // No need to swap-in graphic when getting optional PDF data. return mpPdfData; } @@ -1418,8 +1420,12 @@ bool ImpGraphic::ensureAvailable() const bool ImpGraphic::loadPrepared() { Graphic aGraphic; + // Set the page number to load the correct page (for multipage types). aGraphic.setPageNumber(mnPageNumber); + // Preserve the PdfData since it's shared. + aGraphic.setPdfData(getPdfData()); + if (mpGfxLink->LoadNative(aGraphic)) { *this = *aGraphic.ImplGetImpGraphic(); |