[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sun Apr 26 16:19:34 UTC 2020
vcl/source/gdi/pdfwriter_impl.cxx | 7 ++++++-
vcl/source/gdi/pdfwriter_impl.hxx | 5 ++++-
2 files changed, 10 insertions(+), 2 deletions(-)
New commits:
commit 2d1a0e36ec2eb851b487e75d3103bc76359bb1dd
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Apr 26 12:07:19 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Apr 26 18:19:00 2020 +0200
vcl: When exporintg PDF write the correct page of embedded PDF
We can display PDF as an graphic in the document, where the PDF
is treated as a vector graphic and rendered with Pdfium. When
in that case we export the document as PDF, we can insert the
original PDF page as an reference XObject. This workes fine,
however the PDF as an graphic also contains the page number,
which page should be rendered. This was not taken into account
in the PDF export - it was hardcored to first page.
This extends the support so it reads the page index from the
graphic, and sets the correct PDF page.
Change-Id: I15188ee495f9b3fcc3aa7df6f4bad4fa09903c6a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92923
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 8aec8544431a..c5d0e441254d 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9145,7 +9145,9 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit)
return;
}
- filter::PDFObjectElement* pPage = aPages[0];
+ size_t nPageIndex = rEmit.m_nPDFPageIndex >= 0 ? rEmit.m_nPDFPageIndex : 0;
+
+ filter::PDFObjectElement* pPage = aPages[nPageIndex];
if (!pPage)
{
SAL_WARN("vcl.pdfwriter", "PDFWriterImpl::writeReferenceXObject: no page");
@@ -9699,7 +9701,10 @@ void PDFWriterImpl::createEmbeddedFile(const Graphic& rGraphic, ReferenceXObject
rEmit.m_nEmbeddedObject = m_aEmbeddedFiles.back().m_nObject;
}
else
+ {
+ rEmit.m_nPDFPageIndex = rGraphic.getVectorGraphicData()->getPageIndex();
rEmit.m_aPDFData = *pPDFData;
+ }
rEmit.m_nFormObject = createObject();
rEmit.m_aPixelSize = rGraphic.GetPrefSize();
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index ca3b797d5b6f..98d2f8812059 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -203,13 +203,16 @@ public:
sal_Int32 m_nBitmapObject;
/// Size of the bitmap replacement, in pixels.
Size m_aPixelSize;
+
/// PDF data from the graphic object, if not writing a reference XObject.
std::vector<sal_Int8> m_aPDFData;
+ sal_Int32 m_nPDFPageIndex;
ReferenceXObjectEmit()
: m_nFormObject(0),
m_nEmbeddedObject(0),
- m_nBitmapObject(0)
+ m_nBitmapObject(0),
+ m_nPDFPageIndex(-1)
{
}
More information about the Libreoffice-commits
mailing list