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-04 12:36:28 -0400
commit01c3661b0db04911db5b7c36337f0f80d5bc6640 (patch)
tree28354ad344406d2c4095488b1d4851cc8f0e7553
parent72cde76fc2653eae5d7ca5c7fc0db00aa1011539 (diff)
sd: render the correct PDF page on swapping in
Reviewed-on: https://gerrit.libreoffice.org/54746 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit 4b244589762ad43be15fa637b5d5d12340ccc668) Change-Id: I81225e228d9cf2b9849110715dbfdeb59f2805dd
-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.cxx16
4 files changed, 16 insertions, 15 deletions
diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index 30015be22627..c9e62bb5cb21 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 abc1410d0f91..cb230849d8a8 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -128,11 +128,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()));
@@ -163,8 +160,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 7083c4a9cc99..52a6f7a3af89 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -216,12 +216,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];
@@ -243,7 +243,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 5d022fcf1a65..c78f05c18052 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1887,12 +1887,18 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
rIStm.ReadUInt32(nPdfDataLength);
Bitmap aBitmap;
- if (nPdfDataLength && !rIStm.GetError() &&
- vcl::ImportPDF(rIStm, aBitmap, *rImpGraphic.mpPdfData,
- rIStm.Tell(), nPdfDataLength))
+ if (nPdfDataLength && !rIStm.GetError())
{
- rImpGraphic.maEx = aBitmap;
- rImpGraphic.meType = GraphicType::Bitmap;
+ if (!rImpGraphic.mpPdfData)
+ rImpGraphic.mpPdfData.reset(new uno::Sequence<sal_Int8>());
+
+ if (vcl::ImportPDF(rIStm, aBitmap, rImpGraphic.mnPageNumber,
+ *rImpGraphic.mpPdfData,
+ rIStm.Tell(), nPdfDataLength))
+ {
+ rImpGraphic.maEx = aBitmap;
+ rImpGraphic.meType = GraphicType::Bitmap;
+ }
}
}
else