summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-05-24 01:33:50 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-06 00:53:53 -0400
commit4ecb01c83fd447067638705056f0f8ad74b54ea5 (patch)
tree4f73f31abdc02ac70f84f7c36937c67dd3f34471
parentfc18bc99f360f7a5257451b1efec2df2fb3a0697 (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.hxx2
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx5
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx8
-rw-r--r--vcl/source/gdi/impgraph.cxx3
4 files changed, 7 insertions, 11 deletions
diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index 576c6e258728..4074f9ecc58d 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -32,7 +32,7 @@ class Graphic;
namespace vcl
{
/// Imports a PDF stream into rGraphic as a GDIMetaFile.
-VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Bitmap& rBitmap,
+VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Bitmap& rBitmap, size_t nPageIndex,
css::uno::Sequence<sal_Int8>& rPdfData,
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 d426c0d360ef..a38f27e2497e 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->GetLeftBorder() + pPage->GetRightBorder()));
@@ -164,8 +161,6 @@ bool SdPdfFilter::Import()
aPos.setX(((aPagSize.Width() - aGrfSize.Width()) >> 1) + pPage->GetLeftBorder());
aPos.setY(((aPagSize.Height() - aGrfSize.Height()) >> 1) + pPage->GetUpperBorder());
- SAL_WARN("sd.filter", "Graphic Pos: " << aPos);
- SAL_WARN("sd.filter", "Graphic Logic Size: " << aGrfSize);
pPage->InsertObject(new SdrGrafObj(pPage->getSdrModelFromSdrPage(), aGraphic,
::tools::Rectangle(aPos, aGrfSize)));
}
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 4d272720fdcf..b5fa067a324a 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -209,12 +209,12 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream, sal_uInt64 n
namespace vcl
{
-bool ImportPDF(SvStream& rStream, Bitmap& rBitmap, css::uno::Sequence<sal_Int8>& rPdfData,
- sal_uInt64 nPos, sal_uInt64 nSize)
+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];
@@ -236,7 +236,7 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
{
uno::Sequence<sal_Int8> aPdfData;
Bitmap aBitmap;
- const bool bRet = ImportPDF(rStream, aBitmap, aPdfData);
+ const 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 331f7927e4d2..32c8dfee44a8 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1891,7 +1891,8 @@ void 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;