[Libreoffice-commits] core.git: Branch 'distro/collabora/cd-5.3-3.2' - include/vcl sd/source vcl/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu May 24 16:11:17 UTC 2018


 include/vcl/pdfread.hxx              |    1 +
 sd/source/filter/pdf/sdpdffilter.cxx |    5 -----
 vcl/source/filter/ipdf/pdfread.cxx   |    6 ++++--
 vcl/source/gdi/impgraph.cxx          |    3 ++-
 4 files changed, 7 insertions(+), 8 deletions(-)

New commits:
commit 4b244589762ad43be15fa637b5d5d12340ccc668
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu May 24 01:33:50 2018 -0400

    sd: render the correct PDF page on swapping in
    
    Change-Id: I81225e228d9cf2b9849110715dbfdeb59f2805dd
    Reviewed-on: https://gerrit.libreoffice.org/54746
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

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;


More information about the Libreoffice-commits mailing list