summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-05-24 01:33:50 -0400
committerJan Holesovsky <kendy@collabora.com>2018-05-24 18:10:55 +0200
commit4b244589762ad43be15fa637b5d5d12340ccc668 (patch)
tree727645e0969d96c8ecad86af71d1e6f7d9e69e93
parentfd96a5f499b0ca4b9d8118fedaae6a3222162353 (diff)
sd: render the correct PDF page on swapping in
Change-Id: I81225e228d9cf2b9849110715dbfdeb59f2805dd Reviewed-on: https://gerrit.libreoffice.org/54746 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--include/vcl/pdfread.hxx1
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx5
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx6
-rw-r--r--vcl/source/gdi/impgraph.cxx3
4 files changed, 7 insertions, 8 deletions
diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index 7eb89ce6051b..8fd840685248 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -18,6 +18,7 @@ namespace vcl
/// Imports a PDF stream into rGraphic as a GDIMetaFile.
VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Bitmap &rBitmap,
+ size_t nPageIndex,
css::uno::Sequence<sal_Int8> &rPdfFata,
sal_uInt64 nPos = STREAM_SEEK_TO_BEGIN,
sal_uInt64 nSize = STREAM_SEEK_TO_END);
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index cad414417038..5bca171dc64a 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -129,11 +129,8 @@ bool SdPdfFilter::Import()
// Create the page and insert the Graphic.
SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard);
-
- SAL_WARN("sd.filter", "Graphic PrefSize: " << aGraphic.GetPrefSize());
Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
MapMode(MapUnit::Map100thMM)));
- SAL_WARN("sd.filter", "Graphic Logic Size: " << aGrfSize);
Size aPagSize(pPage->GetSize());
aPagSize.AdjustWidth(-(pPage->GetLftBorder() + pPage->GetRgtBorder()));
@@ -164,8 +161,6 @@ bool SdPdfFilter::Import()
aPos.setX(((aPagSize.Width() - aGrfSize.Width()) >> 1) + pPage->GetLftBorder());
aPos.setY(((aPagSize.Height() - aGrfSize.Height()) >> 1) + pPage->GetUppBorder());
- SAL_WARN("sd.filter", "Graphic Pos: " << aPos);
- SAL_WARN("sd.filter", "Graphic Logic Size: " << aGrfSize);
pPage->InsertObject(new SdrGrafObj(aGraphic, Rectangle(aPos, aGrfSize)));
}
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index ec45de2af5e7..52d8e7277719 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -227,12 +227,14 @@ namespace vcl
{
bool ImportPDF(SvStream& rStream, Bitmap &rBitmap,
+ size_t nPageIndex,
css::uno::Sequence<sal_Int8> &rPdfData,
sal_uInt64 nPos, sal_uInt64 nSize)
{
// Get the preview of the first page.
std::vector<Bitmap> aBitmaps;
- if (generatePreview(rStream, aBitmaps, nPos, nSize, 0, 1) != 1)
+ if (generatePreview(rStream, aBitmaps, nPos, nSize, nPageIndex, 1) != 1 ||
+ aBitmaps.empty())
return false;
rBitmap = aBitmaps[0];
@@ -255,7 +257,7 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
{
uno::Sequence<sal_Int8> aPdfData;
Bitmap aBitmap;
- bool bRet = ImportPDF(rStream, aBitmap, aPdfData);
+ bool bRet = ImportPDF(rStream, aBitmap, 0, aPdfData);
rGraphic = aBitmap;
rGraphic.setPdfData(std::make_shared<css::uno::Sequence<sal_Int8>>(aPdfData));
rGraphic.setPageNumber(0); // We currently import only the first page.
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 98afd8a97920..798b7c85f745 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1578,7 +1578,8 @@ SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
if (!rImpGraphic.mpPdfData)
rImpGraphic.mpPdfData.reset(new uno::Sequence<sal_Int8>());
- if (vcl::ImportPDF(rIStm, aBitmap, *rImpGraphic.mpPdfData,
+ if (vcl::ImportPDF(rIStm, aBitmap, rImpGraphic.mnPageNumber,
+ *rImpGraphic.mpPdfData,
rIStm.Tell(), nPdfDataLength))
{
rImpGraphic.maEx = aBitmap;