[Libreoffice-commits] core.git: include/vcl sd/source vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sat Jun 20 12:24:37 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 03f0ea92bc381ef5a8df7de1ae9edf4aed45a3b2
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: Sat Jun 20 14:24:01 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>
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 55d21f4057b8..2b09bc9e828e 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -41,7 +41,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;
@@ -52,10 +52,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 && o3tl::make_unsigned(nPageNumber) < aGraphics.size());
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 10caf1a975f5..9845c6c387c4 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