[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl sd/source vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 29 18:37:01 UTC 2020


 include/vcl/pdfread.hxx              |   18 ++++++++++++++++--
 sd/source/filter/pdf/sdpdffilter.cxx |    8 ++++----
 vcl/source/filter/ipdf/pdfread.cxx   |    2 +-
 3 files changed, 21 insertions(+), 7 deletions(-)

New commits:
commit 1aa683fb0c54dd409bb3d0a779ca0fd3e9ae8e56
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Jun 15 14:07:04 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 29 20:36:27 2020 +0200

    vcl: add PDFGraphicResult instead of std::pair in ImportPDFUnloaded
    
    ImportPDFUnloaded returned graphics as a vector of std::pair with
    Graphic and Size. Instead, use a new struct PDFGraphicResult, so
    it can be extended in the future.
    
    Change-Id: Idda00a3b98a8efcbd9b8c8d0ee3982becfdc1d7f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96755
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 03f0ea92bc381ef5a8df7de1ae9edf4aed45a3b2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97437
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index ba0eb1ca85be..a65d230279b9 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -13,13 +13,13 @@
 #include <vector>
 #include <tools/gen.hxx>
 #include <tools/stream.hxx>
+#include <vcl/graph.hxx>
 
 namespace com::sun::star::uno
 {
 template <typename> class Sequence;
 }
 class Bitmap;
-class Graphic;
 
 namespace vcl
 {
@@ -31,10 +31,24 @@ VCL_DLLPUBLIC size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vecto
 /// Imports a PDF stream into rGraphic as VectorGraphicData.
 VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic);
 
+struct PDFGraphicResult
+{
+    Graphic maGraphic;
+
+    // Size in HMM
+    Size maSize;
+
+    PDFGraphicResult(Graphic const& rGraphic, Size const& rSize)
+        : maGraphic(rGraphic)
+        , maSize(rSize)
+    {
+    }
+};
+
 /// Import PDF as Graphic images (1 per page), but not loaded yet.
 /// Returns the number of pages read.
 VCL_DLLPUBLIC size_t ImportPDFUnloaded(const OUString& rURL,
-                                       std::vector<std::pair<Graphic, Size>>& rGraphics);
+                                       std::vector<PDFGraphicResult>& rGraphics);
 }
 
 #endif // INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index c1069da58233..91eb0d1a6ae4 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -40,7 +40,7 @@ bool SdPdfFilter::Import()
     const OUString aFileName(
         mrMedium.GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE));
 
-    std::vector<std::pair<Graphic, Size>> aGraphics;
+    std::vector<vcl::PDFGraphicResult> aGraphics;
     if (vcl::ImportPDFUnloaded(aFileName, aGraphics) == 0)
         return false;
 
@@ -51,10 +51,10 @@ bool SdPdfFilter::Import()
         mrDocument.DuplicatePage(0);
     }
 
-    for (const std::pair<Graphic, Size>& aPair : aGraphics)
+    for (vcl::PDFGraphicResult const& rPDFGraphicResult : aGraphics)
     {
-        const Graphic& rGraphic = aPair.first;
-        const Size& aSizeHMM = aPair.second;
+        const Graphic& rGraphic = rPDFGraphicResult.maGraphic;
+        const Size& aSizeHMM = rPDFGraphicResult.maSize;
 
         const sal_Int32 nPageNumber = rGraphic.getPageNumber();
         assert(nPageNumber >= 0 && static_cast<size_t>(nPageNumber) < aGraphics.size());
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 049a51a84257..1a5d98b7e499 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -224,7 +224,7 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
     return true;
 }
 
-size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Size>>& rGraphics)
+size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rGraphics)
 {
 #if HAVE_FEATURE_PDFIUM
     std::unique_ptr<SvStream> xStream(


More information about the Libreoffice-commits mailing list