summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-09 13:01:24 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-17 22:37:55 -0400
commitf8c68132d9f48b5e935a475c5f6de3aaf16da390 (patch)
treea831ec158df297fc723d5b6da6d096be0496d538
parentvcl: share GfxLink (diff)
downloadcore-f8c68132d9f48b5e935a475c5f6de3aaf16da390.tar.gz
core-f8c68132d9f48b5e935a475c5f6de3aaf16da390.zip
vcl: load the correct page when swapping-in a PDF Graphic
Change-Id: I00ffb9f76e763e1c4cd65c5dcea061d6d94d1d6a
-rw-r--r--vcl/source/filter/graphicfilter.cxx1
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx10
-rw-r--r--vcl/source/gdi/impgraph.cxx2
3 files changed, 9 insertions, 4 deletions
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 98fc1032d93b..00471c38bdbb 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -2080,6 +2080,7 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat
}
else if (aFilterName == IMP_PDF)
{
+ // Note: will import rGraphic.getPageNumber if non-negative, or the first.
if (!vcl::ImportPDF(rIStream, rGraphic))
nStatus = GRFILTER_FILTERERROR;
else
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index af8f3ab38c06..016616e69dfc 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -262,14 +262,16 @@ bool ImportPDF(SvStream& rStream, Bitmap &rBitmap,
bool ImportPDF(SvStream& rStream, Graphic& rGraphic,
const double fResolutionDPI)
{
+ // Load the first page implicitly, if a specific one is not requested.
+ if (rGraphic.getPageNumber() < 0)
+ rGraphic.setPageNumber(0);
+
uno::Sequence<sal_Int8> aPdfData;
Bitmap aBitmap;
- bool bRet = ImportPDF(rStream, aBitmap, 0, aPdfData,
- STREAM_SEEK_TO_BEGIN,
- STREAM_SEEK_TO_END, fResolutionDPI);
+ const bool bRet = ImportPDF(rStream, aBitmap, rGraphic.getPageNumber(), aPdfData,
+ STREAM_SEEK_TO_BEGIN, STREAM_SEEK_TO_END, fResolutionDPI);
rGraphic = aBitmap;
rGraphic.setPdfData(std::make_shared<css::uno::Sequence<sal_Int8>>(aPdfData));
- rGraphic.setPageNumber(0); // We currently import only the first page.
return bRet;
}
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index a34573347d7f..2c2ba1bef9ca 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1418,6 +1418,8 @@ bool ImpGraphic::ensureAvailable() const
bool ImpGraphic::loadPrepared()
{
Graphic aGraphic;
+ // Set the page number to load the correct page (for multipage types).
+ aGraphic.setPageNumber(mnPageNumber);
if (mpGfxLink->LoadNative(aGraphic))
{
*this = *aGraphic.ImplGetImpGraphic();