[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sun Apr 26 11:16:05 UTC 2020


 vcl/source/gdi/pdfwriter_impl.cxx |    7 ++++++-
 vcl/source/gdi/pdfwriter_impl.hxx |    4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit facb74a381853e53602cf17d53cc2ad3d6b4bb29
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Apr 26 12:07:19 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sun Apr 26 13:07:32 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

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 9a8a93076d2e..cb7f4cc17027 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8613,7 +8613,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");
@@ -9205,7 +9207,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 71de229f2c41..e775fc92a4af 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -188,11 +188,13 @@ struct ReferenceXObjectEmit
     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