[Libreoffice-commits] core.git: include/vcl vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Dec 21 09:49:56 UTC 2020
include/vcl/pdfread.hxx | 7 ++++++-
vcl/source/filter/ipdf/pdfread.cxx | 17 +++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
New commits:
commit 0df9ea8d654103256a67f4a6977468bd01a00f01
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 15 16:54:46 2020 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Dec 21 10:49:12 2020 +0100
pdf: add a public function to load PDF as a VectorGraphicData
This adds a public function that loads a PDF as a VectorGraphicData
which essentially spilts the ImportPDF to general import as a
VectorGraphicData and then creation of a new Graphic. This is
needed so we can just load the VectorGraphicData independent to
a Graphic itself, so we don't needlessly create a new Graphic
instance in some cases.
Change-Id: Ib5f570242da69a1537bfdf1054f8eb40ecead31b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107991
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index b693c432302b..084bd3f913b5 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -34,7 +34,12 @@ VCL_DLLPUBLIC size_t RenderPDFBitmaps(const void* pBuffer, int nSize,
std::vector<BitmapEx>& rBitmaps, size_t nFirstPage = 0,
int nPages = 1, const basegfx::B2DTuple* pSizeHint = nullptr);
-/// Imports a PDF stream into rGraphic as VectorGraphicData.
+/// Imports a PDF stream as a VectorGraphicData.
+VCL_DLLPUBLIC bool
+importPdfVectorGraphicData(SvStream& rStream,
+ std::shared_ptr<VectorGraphicData>& rVectorGraphicData);
+
+/// Imports a PDF stream into rGraphic.
VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic);
struct PDFGraphicAnnotation
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index ef5d799fe4ee..dbfa5ceeaf68 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -230,7 +230,8 @@ size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<BitmapEx>& r
#endif // HAVE_FEATURE_PDFIUM
}
-bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
+bool importPdfVectorGraphicData(SvStream& rStream,
+ std::shared_ptr<VectorGraphicData>& rVectorGraphicData)
{
VectorGraphicDataArray aPdfDataArray = createVectorGraphicDataArray(rStream);
if (!aPdfDataArray.hasElements())
@@ -239,10 +240,18 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
return false;
}
- auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aPdfDataArray, OUString(),
- VectorGraphicDataType::Pdf);
+ rVectorGraphicData = std::make_shared<VectorGraphicData>(aPdfDataArray, OUString(),
+ VectorGraphicDataType::Pdf);
+
+ return true;
+}
- rGraphic = Graphic(aVectorGraphicDataPtr);
+bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
+{
+ std::shared_ptr<VectorGraphicData> pVectorGraphicData;
+ if (!importPdfVectorGraphicData(rStream, pVectorGraphicData))
+ return false;
+ rGraphic = Graphic(pVectorGraphicData);
return true;
}
More information about the Libreoffice-commits
mailing list